コード例 #1
0
        public virtual async void TestDelete()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);
            var        client     = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;

            IChainService service = testServer.Host.Services.GetService(typeof(IChainService)) as IChainService;
            var           model   = new ApiChainServerRequestModel();

            model.SetProperties(1, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B", 1);
            CreateResponse <ApiChainServerResponseModel> createdResponse = await service.Create(model);

            createdResponse.Success.Should().BeTrue();

            ActionResponse deleteResult = await client.ChainDeleteAsync(2);

            deleteResult.Success.Should().BeTrue();
            ApiChainServerResponseModel verifyResponse = await service.Get(2);

            verifyResponse.Should().BeNull();
        }
コード例 #2
0
ファイル: BlockCollection.cs プロジェクト: wyk125/AElf
        public BlockCollection(IChainService chainService, ILogger logger = null)
        {
            _chainService = chainService;
            _logger       = logger;

            _heightBefore = BlockChain.GetCurrentBlockHeightAsync().Result;
        }
コード例 #3
0
        public PeerManager(IConnectionListener connectionListener, IChainService chainService, ILogger logger)
        {
            _jobQueue    = new BlockingCollection <PeerManagerJob>();
            _bpAddresses = new List <byte[]>();
            _whiteList   = new List <byte[]>();

            _connectionListener = connectionListener;
            _chainService       = chainService;
            //_blockChain = blockChain;
            _logger = logger;

            _nodeName = NodeConfig.Instance.NodeName;

            if (!string.IsNullOrWhiteSpace(NetworkConfig.Instance.NetAllowed))
            {
                if (Enum.TryParse(NetworkConfig.Instance.NetAllowed, out AllowedConnection myName))
                {
                    _allowedConnections = myName;
                }
            }

            if (NetworkConfig.Instance.NetWhitelist != null)
            {
                foreach (var peer in NetworkConfig.Instance.NetWhitelist)
                {
                    _whiteList.Add(ByteArrayHelpers.FromHexString(peer));
                }
            }

            SetBpConfig();
        }
コード例 #4
0
ファイル: MockSetup.cs プロジェクト: wyk125/AElf
        private void Initialize()
        {
            _transactionManager        = new TransactionManager(_dataStore, _logger);
            _transactionReceiptManager = new TransactionReceiptManager(_database);
            _smartContractManager      = new SmartContractManager(_dataStore);
            _transactionResultManager  = new TransactionResultManager(_dataStore);
            _transactionTraceManager   = new TransactionTraceManager(_dataStore);
            _functionMetadataService   = new FunctionMetadataService(_dataStore, _logger);
            _chainManagerBasic         = new ChainManagerBasic(_dataStore);
            _chainService = new ChainService(_chainManagerBasic, new BlockManagerBasic(_dataStore),
                                             _transactionManager, _transactionTraceManager, _dataStore, StateStore);
            _smartContractRunnerFactory = new SmartContractRunnerFactory();

            /*var runner = new SmartContractRunner("../../../../AElf.SDK.CSharp/bin/Debug/netstandard2.0/");
             * _smartContractRunnerFactory.AddRunner(0, runner);*/
            var runner = new SmartContractRunner(ContractCodes.TestContractFolder);

            _smartContractRunnerFactory.AddRunner(0, runner);
            _concurrencyExecutingService = new SimpleExecutingService(
                new SmartContractService(_smartContractManager, _smartContractRunnerFactory, StateStore,
                                         _functionMetadataService), _transactionTraceManager, StateStore,
                new ChainContextService(_chainService));

            _chainCreationService = new ChainCreationService(_chainService,
                                                             new SmartContractService(new SmartContractManager(_dataStore), _smartContractRunnerFactory,
                                                                                      StateStore, _functionMetadataService), _logger);

            _binaryMerkleTreeManager = new BinaryMerkleTreeManager(_dataStore);
            _chainContextService     = new ChainContextService(_chainService);
            _stateStore = new StateStore(_database);
        }
コード例 #5
0
        private void Initialize()
        {
            NewStorage();
            var transactionManager      = new TransactionManager(_dataStore, _logger);
            var transactionTraceManager = new TransactionTraceManager(_dataStore);

            _functionMetadataService = new FunctionMetadataService(_dataStore, _logger);
            var chainManagerBasic = new ChainManagerBasic(_dataStore);

            ChainService = new ChainService(chainManagerBasic, new BlockManagerBasic(_dataStore),
                                            transactionManager, transactionTraceManager, _dataStore, StateStore);
            _smartContractRunnerFactory = new SmartContractRunnerFactory();
            var runner = new SmartContractRunner("../../../../AElf.Runtime.CSharp.Tests.TestContract/bin/Debug/netstandard2.0/");

            _smartContractRunnerFactory.AddRunner(0, runner);
            _chainCreationService = new ChainCreationService(ChainService,
                                                             new SmartContractService(new SmartContractManager(_dataStore), _smartContractRunnerFactory,
                                                                                      StateStore, _functionMetadataService), _logger);
            SmartContractManager = new SmartContractManager(_dataStore);
            Task.Factory.StartNew(async() =>
            {
                await Init();
            }).Unwrap().Wait();
            SmartContractService = new SmartContractService(SmartContractManager, _smartContractRunnerFactory, StateStore, _functionMetadataService);
            ChainService         = new ChainService(new ChainManagerBasic(_dataStore), new BlockManagerBasic(_dataStore), new TransactionManager(_dataStore), new TransactionTraceManager(_dataStore), _dataStore, StateStore);
        }
コード例 #6
0
 public TxValidator(ITxPoolConfig config, IChainService chainService, ILogger logger)
 {
     _config                  = config;
     _chainService            = chainService;
     _logger                  = logger;
     _canonicalBlockHashCache = new CanonicalBlockHashCache(BlockChain, logger);
 }
コード例 #7
0
 public ParentChainBlockInfoRpcServerImpl(IChainService chainService, ILogger logger,
                                          IBinaryMerkleTreeManager binaryMerkleTreeManager)
 {
     _chainService            = chainService;
     _logger                  = logger;
     _binaryMerkleTreeManager = binaryMerkleTreeManager;
 }
コード例 #8
0
ファイル: Program.cs プロジェクト: ZoroChain/Zoro.Benchmark
        static void Main(string[] args)
        {
            try
            {
                // Create service collection
                ServiceCollection serviceCollection = new ServiceCollection();
                ConfigureServices(serviceCollection);

                // create neo services collection
                ConfigureNeoServices(serviceCollection);

                // Create service provider
                IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();

                // Run service
                IEnumerator <IChainService> services = serviceProvider.GetServices <IChainService>().GetEnumerator();
                while (services.MoveNext())
                {
                    IChainService service = services.Current;
                    service.Run(new Dictionary <string, object>());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                _logger.LogError(ex.StackTrace);
            }
        }
コード例 #9
0
ファイル: StoragesTest.cs プロジェクト: wyk125/AElf
 public StoragesTest(IDataStore dataStore, BlockTest blockTest, IChainService chainService, ILogger logger)
 {
     _dataStore    = dataStore;
     _blockTest    = blockTest;
     _chainService = chainService;
     _logger       = logger;
 }
コード例 #10
0
 public RecordService(IChainService chainService, ITransactionService transactionService, INodeService nodeService, INetworkService networkService)
 {
     _chainService       = chainService;
     _transactionService = transactionService;
     _nodeService        = nodeService;
     _networkService     = networkService;
     _timer          = new Timer(ManagementConfig.Instance.MonitoringInterval * 1000);
     _timer.Elapsed += TimerOnElapsed;
 }
コード例 #11
0
 public SplashViewModel(IWalletService walletService, ISettingService settingService,
                        IAddressManagerService addressManagerService, IChainService chainService,
                        IOperationTrackerService trackerService)
 {
     this.walletService         = walletService;
     this.settingService        = settingService;
     this.addressManagerService = addressManagerService;
     this.chainService          = chainService;
     this.trackerService        = trackerService;
     AppName = "CoinBag";
 }
コード例 #12
0
 public GameService(ILoggerFactory loggerFactory, IMapper mapper,
                    IGameService defaultGameService, IEntryService defaultEntryService,
                    IEventService defaultEventService, IChainService defaultChainService)
 {
     _mapper              = mapper;
     _logger              = loggerFactory.CreateLogger <GameService>();
     _defaultGameService  = defaultGameService;
     _defaultEntryService = defaultEntryService;
     _defaultEventService = defaultEventService;
     _defaultChainService = defaultChainService;
 }
コード例 #13
0
 public MainchainNodeService(IStateStore stateStore, ITxHub hub, IChainCreationService chainCreationService,
                             IBlockSynchronizer blockSynchronizer, IChainService chainService, IMiner miner, ILogger logger)
 {
     _stateStore           = stateStore;
     _chainCreationService = chainCreationService;
     _chainService         = chainService;
     _txHub             = hub;
     _logger            = logger;
     _miner             = miner;
     _blockSynchronizer = blockSynchronizer;
 }
コード例 #14
0
 public AbstractChainController(
     ApiSettings settings,
     ILogger <AbstractChainController> logger,
     ITransactionCoordinator transactionCoordinator,
     IChainService chainService,
     IApiChainModelMapper chainModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.ChainService     = chainService;
     this.ChainModelMapper = chainModelMapper;
 }
コード例 #15
0
ファイル: BlockExecutor.cs プロジェクト: shiwk/AElf
        public BlockExecutor(IChainService chainService, IExecutingService executingService,
                             ITransactionResultManager transactionResultManager, ClientManager clientManager,
                             IBinaryMerkleTreeManager binaryMerkleTreeManager, ITxHub txHub, IChainManagerBasic chainManagerBasic, IStateStore stateStore)
        {
            _chainService             = chainService;
            _executingService         = executingService;
            _transactionResultManager = transactionResultManager;
            _clientManager            = clientManager;
            _binaryMerkleTreeManager  = binaryMerkleTreeManager;
            _txHub             = txHub;
            _chainManagerBasic = chainManagerBasic;
            _stateStore        = stateStore;
            _dpoSInfoProvider  = new DPoSInfoProvider(_stateStore);

            _logger = LogManager.GetLogger(nameof(BlockExecutor));

            MessageHub.Instance.Subscribe <DPoSStateChanged>(inState => _isMining = inState.IsMining);

            _executing         = false;
            _prepareTerminated = false;
            _terminated        = false;

            MessageHub.Instance.Subscribe <TerminationSignal>(signal =>
            {
                if (signal.Module == TerminatedModuleEnum.BlockExecutor)
                {
                    if (!_executing)
                    {
                        _terminated = true;
                        MessageHub.Instance.Publish(new TerminatedModule(TerminatedModuleEnum.BlockExecutor));
                    }
                    else
                    {
                        _prepareTerminated = true;
                    }
                }
            });

            MessageHub.Instance.Subscribe <StateEvent>(inState =>
            {
                if (inState == StateEvent.RollbackFinished)
                {
                    _isLimitExecutionTime = false;
                }

                if (inState == StateEvent.MiningStart)
                {
                    _isLimitExecutionTime = true;
                }

                _logger?.Trace($"Current Event: {inState.ToString()} ,IsLimitExecutionTime: {_isLimitExecutionTime}");
            });
        }
コード例 #16
0
ファイル: MainViewModel.cs プロジェクト: long20p/CoinBag
        public MainViewModel(IAddressManagerService addressManagerService, IChainService chainService, IOperationTrackerService trackerService, IWalletService walletService)
        {
            this.addressManagerService = addressManagerService;
            this.chainService          = chainService;
            this.trackerService        = trackerService;
            this.walletService         = walletService;

            Title = "Coin bag";

            RecentTransactions  = new ObservableRangeCollection <TransactionDetail>();
            GoToGetCoinCommand  = new Command(GoToGetCoinCommandExecute);
            GoToSendCoinCommand = new Command(GoToSendCoinCommandExecute);
        }
コード例 #17
0
        public TxHub(ITransactionManager transactionManager, ITransactionReceiptManager receiptManager,
                     IChainService chainService,
                     ITxSignatureVerifier signatureVerifier,
                     ITxRefBlockValidator refBlockValidator)
        {
            _transactionManager = transactionManager;
            _receiptManager     = receiptManager;
            _chainService       = chainService;
            _signatureVerifier  = signatureVerifier;
            _refBlockValidator  = refBlockValidator;

            _terminated = false;
        }
コード例 #18
0
        public RecordService(IChainService chainService, ITransactionService transactionService, INodeService
                             nodeService, INetworkService networkService, IOptionsSnapshot <ManagementOptions> options)
        {
            Logger = NullLogger <RecordService> .Instance;

            _chainService       = chainService;
            _transactionService = transactionService;
            _nodeService        = nodeService;
            _networkService     = networkService;
            _managementOptions  = options.Value;
            _timer          = new Timer(_managementOptions.MonitoringInterval * 1000);
            _timer.Elapsed += TimerOnElapsed;
        }
コード例 #19
0
ファイル: ChainController.cs プロジェクト: codenesium/samples
 public ChainController(
     ApiSettings settings,
     ILogger <ChainController> logger,
     ITransactionCoordinator transactionCoordinator,
     IChainService chainService,
     IApiChainServerModelMapper chainModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.ChainService     = chainService;
     this.ChainModelMapper = chainModelMapper;
     this.BulkInsertLimit  = 250;
     this.MaxLimit         = 1000;
     this.DefaultLimit     = 250;
 }
コード例 #20
0
ファイル: TransactionResultTest.cs プロジェクト: wyk125/AElf
        public TransactionResultTest(ITxPoolConfig txPoolConfig, IChainService chainService,
                                     ITxSignatureVerifier signatureVerifier, ITxRefBlockValidator refBlockValidator,
                                     ITransactionResultManager transactionResultManager, ITxHub txHub)
        {
            ChainConfig.Instance.ChainId    = Hash.Generate().DumpHex();
            NodeConfig.Instance.NodeAccount = Address.Generate().DumpHex();
            _transactionResultManager       = transactionResultManager;
            _signatureVerifier = signatureVerifier;
            _refBlockValidator = refBlockValidator;
            _txHub             = txHub;
//            _transactionResultService = new TransactionResultService(
//                new TxPool(logger,
//                    new NewTxHub(transactionManager, chainService, signatureVerifier, refBlockValidator)), transactionResultManager);
            _transactionResultService = new TransactionResultService(_txHub, _transactionResultManager);
        }
コード例 #21
0
ファイル: ContractTest.cs プロジェクト: wyk125/AElf
 public ContractTest(IStateStore stateStore,
                     IChainCreationService chainCreationService, IChainService chainService,
                     ITransactionManager transactionManager, ISmartContractManager smartContractManager,
                     IChainContextService chainContextService, IFunctionMetadataService functionMetadataService, ISmartContractRunnerFactory smartContractRunnerFactory)
 {
     _stateStore                 = stateStore;
     _chainCreationService       = chainCreationService;
     _chainService               = chainService;
     _transactionManager         = transactionManager;
     _smartContractManager       = smartContractManager;
     _chainContextService        = chainContextService;
     _functionMetadataService    = functionMetadataService;
     _smartContractRunnerFactory = smartContractRunnerFactory;
     _smartContractService       = new SmartContractService(_smartContractManager, _smartContractRunnerFactory, stateStore, _functionMetadataService);
 }
コード例 #22
0
ファイル: BlockExecutionService.cs プロジェクト: wyk125/AElf
        public BlockExecutionService(IExecutingService executingService, ITxPoolService txPoolService,
                                     IChainService chainService, ITransactionManager transactionManager,
                                     ITransactionResultManager transactionResultManager, IStateDictator stateDictator,
                                     IBinaryMerkleTreeManager binaryMerkleTreeManager)
        {
            _executingService         = executingService;
            _txPoolService            = txPoolService;
            _chainService             = chainService;
            _transactionManager       = transactionManager;
            _transactionResultManager = transactionResultManager;
            _stateDictator            = stateDictator;
            _binaryMerkleTreeManager  = binaryMerkleTreeManager;

            _logger = LogManager.GetLogger(nameof(BlockExecutionService));
        }
コード例 #23
0
ファイル: MockSetup.cs プロジェクト: wyk125/AElf
        public MockSetup(IDataStore dataStore, IChainCreationService chainCreationService,
                         IChainService chainService, IActorEnvironment actorEnvironment,
                         IChainContextService chainContextService, IFunctionMetadataService functionMetadataService,
                         ISmartContractRunnerFactory smartContractRunnerFactory, ILogger logger,
                         IStateStore stateStore, HashManager hashManager, TransactionManager transactionManager)
        {
            _logger          = logger;
            _stateStore      = stateStore;
            ActorEnvironment = actorEnvironment;
            if (!ActorEnvironment.Initialized)
            {
                ActorEnvironment.InitActorSystem();
            }
            _hashManager                = hashManager;
            _transactionManager         = transactionManager;
            _chainCreationService       = chainCreationService;
            _chainService               = chainService;
            ChainContextService         = chainContextService;
            _functionMetadataService    = functionMetadataService;
            _smartContractRunnerFactory = smartContractRunnerFactory;
            SmartContractManager        = new SmartContractManager(dataStore);
            Task.Factory.StartNew(async() => { await Init(); }).Unwrap().Wait();
            SmartContractService =
                new SmartContractService(SmartContractManager, _smartContractRunnerFactory, stateStore,
                                         functionMetadataService);
            Task.Factory.StartNew(async() => { await DeploySampleContracts(); }).Unwrap().Wait();
            ServicePack = new ServicePack()
            {
                ChainContextService      = chainContextService,
                SmartContractService     = SmartContractService,
                ResourceDetectionService = new NewMockResourceUsageDetectionService(),
                StateStore = _stateStore
            };

            // These are only required for workertest
            // other tests use ActorEnvironment
            var workers = new[] { "/user/worker1", "/user/worker2" };

            Worker1 = Sys.ActorOf(Props.Create <Worker>(), "worker1");
            Worker2 = Sys.ActorOf(Props.Create <Worker>(), "worker2");
            Router  = Sys.ActorOf(Props.Empty.WithRouter(new TrackedGroup(workers)), "router");
            Worker1.Tell(new LocalSerivcePack(ServicePack));
            Worker2.Tell(new LocalSerivcePack(ServicePack));
            Requestor = Sys.ActorOf(AElf.Execution.Execution.Requestor.Props(Router));
        }
コード例 #24
0
 public BlockChainTests_MockSetup(IDataStore dataStore, IChainCreationService chainCreationService,
                                  IChainService chainService,
                                  IChainContextService chainContextService, IFunctionMetadataService functionMetadataService,
                                  ISmartContractRunnerFactory smartContractRunnerFactory, ILogger logger,
                                  IStateStore stateStore, HashManager hashManager, TransactionManager transactionManager)
 {
     _logger                     = logger;
     _stateStore                 = stateStore;
     _hashManager                = hashManager;
     _transactionManager         = transactionManager;
     _chainCreationService       = chainCreationService;
     ChainService                = chainService;
     ChainContextService         = chainContextService;
     _functionMetadataService    = functionMetadataService;
     _smartContractRunnerFactory = smartContractRunnerFactory;
     SmartContractManager        = new SmartContractManager(dataStore);
     Task.Factory.StartNew(async() => { await Init(); }).Unwrap().Wait();
     SmartContractService =
         new SmartContractService(SmartContractManager, _smartContractRunnerFactory, stateStore,
                                  functionMetadataService);
     Task.Factory.StartNew(async() => { await DeploySampleContracts(); }).Unwrap().Wait();
 }
コード例 #25
0
ファイル: Miner.cs プロジェクト: wyk125/AElf
        public Miner(IMinerConfig config, ITxHub txHub, IChainService chainService,
                     IExecutingService executingService, ITransactionResultManager transactionResultManager,
                     ILogger logger, ClientManager clientManager,
                     IBinaryMerkleTreeManager binaryMerkleTreeManager, ServerManager serverManager,
                     IBlockValidationService blockValidationService, IChainContextService chainContextService, IChainManagerBasic chainManagerBasic, IStateStore stateStore)
        {
            Config                    = config;
            _txHub                    = txHub;
            _chainService             = chainService;
            _executingService         = executingService;
            _transactionResultManager = transactionResultManager;
            _logger                   = logger;
            _clientManager            = clientManager;
            _binaryMerkleTreeManager  = binaryMerkleTreeManager;
            _serverManager            = serverManager;
            _blockValidationService   = blockValidationService;
            _chainContextService      = chainContextService;
            _chainManagerBasic        = chainManagerBasic;
            _txFilter                 = new TransactionFilter();
            _dpoSInfoProvider         = new DPoSInfoProvider(stateStore);

            _maxMineTime = ConsensusConfig.Instance.DPoSMiningInterval * NodeConfig.Instance.RatioMine;
        }
コード例 #26
0
        public virtual async void TestUpdate()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            var mapper = new ApiChainServerModelMapper();
            ApplicationDbContext        context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IChainService               service = testServer.Host.Services.GetService(typeof(IChainService)) as IChainService;
            ApiChainServerResponseModel model   = await service.Get(1);

            ApiChainClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(1, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B", 1);

            UpdateResponse <ApiChainClientResponseModel> updateResponse = await client.ChainUpdateAsync(model.Id, request);

            context.Entry(context.Set <Chain>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <Chain>().ToList()[0].ChainStatusId.Should().Be(1);
            context.Set <Chain>().ToList()[0].ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            context.Set <Chain>().ToList()[0].Name.Should().Be("B");
            context.Set <Chain>().ToList()[0].TeamId.Should().Be(1);

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.ChainStatusId.Should().Be(1);
            updateResponse.Record.ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            updateResponse.Record.Name.Should().Be("B");
            updateResponse.Record.TeamId.Should().Be(1);
        }
コード例 #27
0
 public BlockchainApiController(IChainService chainService, ILogger <BlockchainApiController> logger, IMapperService mapper)
 {
     _chainService = chainService;
     _logger       = logger;
     _mapper       = mapper;
 }
コード例 #28
0
 public ChainController(IChainService chainService)
 {
     _chainService = chainService;
 }
コード例 #29
0
 public BlockTest(IChainService chainService, IChainCreationService chainCreationService)
 {
     //_smartContractZero = smartContractZero;
     _chainCreationService = chainCreationService;
     _chainService         = chainService;
 }
コード例 #30
0
ファイル: DPoS.cs プロジェクト: wyk125/AElf
        public DPoS(IStateStore stateStore, ITxHub txHub, IMiner miner, IChainService chainService)
        {
            _txHub             = txHub;
            _miner             = miner;
            _chainService      = chainService;
            _prepareTerminated = false;
            _terminated        = false;

            _logger = LogManager.GetLogger(nameof(DPoS));

            Helper = new AElfDPoSHelper(Hash.LoadHex(ChainConfig.Instance.ChainId), Miners,
                                        ContractAddress, stateStore);

            Provider = new DPoSInfoProvider(stateStore);

            var count = MinersConfig.Instance.Producers.Count;

            GlobalConfig.BlockProducerNumber    = count;
            GlobalConfig.BlockNumberOfEachRound = count + 1;

            _logger?.Info("Block Producer nodes count:" + GlobalConfig.BlockProducerNumber);
            _logger?.Info("Blocks of one round:" + GlobalConfig.BlockNumberOfEachRound);

            if (GlobalConfig.BlockProducerNumber == 1 && NodeConfig.Instance.IsMiner)
            {
                AElfDPoSObserver.RecoverMining();
            }

            MessageHub.Instance.Subscribe <UpdateConsensus>(async option =>
            {
                if (option == UpdateConsensus.Update)
                {
                    _logger?.Trace("UpdateConsensus - Update");
                    await Update();
                }

                if (option == UpdateConsensus.Dispose)
                {
                    _logger?.Trace("UpdateConsensus - Dispose");
                    Stop();
                }
            });

            MessageHub.Instance.Subscribe <LockMining>(async inState =>
            {
                if (inState.Lock)
                {
                    IncrementLockNumber();
                }
                else
                {
                    await Start();
                }
            });

            MessageHub.Instance.Subscribe <TerminationSignal>(signal =>
            {
                if (signal.Module == TerminatedModuleEnum.Mining)
                {
                    _prepareTerminated = true;
                }
            });

            MessageHub.Instance.Subscribe <FSMStateChanged>(inState => { CurrentState = inState.CurrentState; });
        }