Esempio n. 1
0
        public void Setup()
        {
            _container?.Dispose();
            TestUtils.DeleteTestChainData();

            var containerBuilder = new SimpleInjectorContainerBuilder(new ConfigManager(
                                                                          Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config2.json"),
                                                                          new RunOptions()
                                                                          ));

            containerBuilder.RegisterModule <BlockchainModule>();
            containerBuilder.RegisterModule <ConfigModule>();
            containerBuilder.RegisterModule <StorageModule>();
            containerBuilder.RegisterModule <ConsensusModule>();
            containerBuilder.RegisterModule <NetworkModule>();

            _container = containerBuilder.Build();


            _privateWallet          = _container.Resolve <IPrivateWallet>();
            _validatorStatusManager = _container.Resolve <IValidatorStatusManager>();
            _configManager          = _container.Resolve <IConfigManager>();
            _transactionBuilder     = _container.Resolve <ITransactionBuilder>();

            ServiceBinder.BindService <GenericParameterAttributes>();
            _apiService = new ValidatorServiceWeb3(_validatorStatusManager, _privateWallet, _transactionBuilder);
        }
Esempio n. 2
0
        public SLH(SLHClient client, SLHWebSocketServer server)
        {
            Client = client;
            Server = server;

            Server.ReceivedMessage += HandleReceivedMessage;

            Client.Network.LoginProgress += HandleLoginProgress;
            Client.Network.LoggedOut     += HandleLoggedOut;

            SessionId = new Guid().ToString();

            // Important step
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings
            {
                //Converters = new[] { JSONConverter }, // Pass the shared (static) converter
                Converters = new[] { new SLHJSONConverter() },
                Error      = delegate(object sender, ErrorEventArgs args)
                {
                    // SERIALIZE ALL THE THINGS!
                    args.ErrorContext.Handled = true;
                },
            };

            // Bind this class to the JSON-RPC server
            ServiceBinder.BindService(SessionId, this);

            // Set up the JSON-RPC client serializer
            JSONRPCSerializer = new JsonRpcSerializer();
        }
Esempio n. 3
0
        public void Setup()
        {
            _container?.Dispose();
            TestUtils.DeleteTestChainData();

            var containerBuilder = new SimpleInjectorContainerBuilder(new ConfigManager(
                                                                          Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config2.json"),
                                                                          new RunOptions()
                                                                          ));

            containerBuilder.RegisterModule <BlockchainModule>();
            containerBuilder.RegisterModule <ConfigModule>();
            containerBuilder.RegisterModule <StorageModule>();
            _container = containerBuilder.Build();

            _configManager              = _container.Resolve <IConfigManager>();
            _stateManager               = _container.Resolve <IStateManager>();
            _transactionPool            = _container.Resolve <ITransactionPool>();
            _transactionSigner          = _container.Resolve <ITransactionSigner>();
            _systemContractReader       = _container.Resolve <ISystemContractReader>();
            _localTransactionRepository = _container.Resolve <ILocalTransactionRepository>();
            _privateWallet              = _container.Resolve <IPrivateWallet>();
            _transactionManager         = _container.Resolve <ITransactionManager>();
            _validatorStatusManager     = _validatorStatusManager = new ValidatorStatusManager(
                _transactionPool, _container.Resolve <ITransactionSigner>(), _container.Resolve <ITransactionBuilder>(),
                _privateWallet, _stateManager, _container.Resolve <IValidatorAttendanceRepository>(),
                _container.Resolve <ISystemContractReader>()
                );
            ServiceBinder.BindService <GenericParameterAttributes>();
            _fes = new FrontEndService(_stateManager, _transactionPool, _transactionSigner,
                                       _systemContractReader, _localTransactionRepository, _validatorStatusManager, _privateWallet, _transactionManager);
        }
Esempio n. 4
0
 public void Bind(string sessionName, AppDomain domain, List <Assembly> assList)
 {
     try
     {
         ServiceBinder.BindService(sessionName, domain: domain, assList: assList);
         FilterBinder.BindFilter(sessionName, domain: domain, assList: assList);
     }
     catch (Exception ex)
     {
     }
 }
Esempio n. 5
0
        public void Setup()
        {
            _container?.Dispose();
            TestUtils.DeleteTestChainData();

            var containerBuilder = new SimpleInjectorContainerBuilder(new ConfigManager(
                                                                          Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config2.json"),
                                                                          new RunOptions()
                                                                          ));

            containerBuilder.RegisterModule <BlockchainModule>();
            containerBuilder.RegisterModule <ConfigModule>();
            containerBuilder.RegisterModule <StorageModule>();
            _container = containerBuilder.Build();


            _configManager        = _container.Resolve <IConfigManager>();
            _stateManager         = _container.Resolve <IStateManager>();
            _contractRegisterer   = _container.Resolve <IContractRegisterer>();
            _privateWallet        = _container.Resolve <IPrivateWallet>();
            _snapshotIndexer      = _container.Resolve <ISnapshotIndexRepository>();
            _systemContractReader = _container.Resolve <ISystemContractReader>();

            _transactionManager = _container.Resolve <ITransactionManager>();
            _transactionBuilder = _container.Resolve <ITransactionBuilder>();
            _transactionSigner  = _container.Resolve <ITransactionSigner>();
            _transactionPool    = _container.Resolve <ITransactionPool>();
            _blockManager       = _container.Resolve <IBlockManager>();

            // set chainId from config
            if (TransactionUtils.ChainId(false) == 0)
            {
                var chainId    = _configManager.GetConfig <NetworkConfig>("network")?.ChainId;
                var newChainId = _configManager.GetConfig <NetworkConfig>("network")?.ChainId;
                TransactionUtils.SetChainId((int)chainId !, (int)newChainId !);
                HardforkHeights.SetHardforkHeights(_configManager.GetConfig <HardforkConfig>("hardfork") ?? throw new InvalidOperationException());
            }
            ServiceBinder.BindService <GenericParameterAttributes>();

            _apiService = new AccountServiceWeb3(_stateManager, _snapshotIndexer, _contractRegisterer, _systemContractReader, _transactionPool);

            _transactionApiService = new TransactionServiceWeb3(_stateManager, _transactionManager, _transactionBuilder, _transactionSigner,
                                                                _transactionPool, _contractRegisterer, _privateWallet);

            _blockManager.TryBuildGenesisBlock();
        }
 public void Bind()
 {
     ServiceBinder.BindService(Handler.DefaultSessionId(), this);
 }
Esempio n. 7
0
 protected JsonRpcService()
 {
     ServiceBinder.BindService(Handler.DefaultSessionId(), this);
 }
Esempio n. 8
0
 /// <summary>
 ///     Routing by SessionId
 /// </summary>
 /// <param name="sessionID"></param>
 protected JsonRpcService(string sessionID)
 {
     ServiceBinder.BindService(sessionID, this);
 }
Esempio n. 9
0
 public void Bind(string sessionName, AppDomain domain, List <Assembly> list)
 {
     ServiceBinder.BindService(sessionName, AppDomain.CurrentDomain);
     TimingTasksBind.BindTask(domain);                //绑定任务
     TimingTasksBind.GetTimerManager().StartTiming(); //启动任务监听
 }