示例#1
0
        public Task InitRpcModules()
        {
            if (_mergeConfig.Enabled)
            {
                IConsensusRpcModule consensusRpcModule = new ConsensusRpcModule();
                _api.RpcModuleProvider !.RegisterSingle <IConsensusRpcModule>(consensusRpcModule);
                if (_logger.IsInfo)
                {
                    _logger.Info("Consensus Module has been enabled");
                }
            }

            return(Task.CompletedTask);
        }
示例#2
0
        public async Task InitRpcModules()
        {
            if (_mergeConfig.Enabled)
            {
                if (_api.RpcModuleProvider is null)
                {
                    throw new ArgumentException(nameof(_api.RpcModuleProvider));
                }
                if (_api.BlockTree is null)
                {
                    throw new ArgumentException(nameof(_api.BlockTree));
                }
                if (_api.BlockchainProcessor is null)
                {
                    throw new ArgumentException(nameof(_api.BlockchainProcessor));
                }
                if (_api.StateProvider is null)
                {
                    throw new ArgumentException(nameof(_api.StateProvider));
                }
                if (_api.StateProvider is null)
                {
                    throw new ArgumentException(nameof(_api.StateProvider));
                }

                await _api.BlockchainProcessor.StopAsync(true);

                IConsensusRpcModule consensusRpcModule = new ConsensusRpcModule(
                    new AssembleBlockHandler(_api.BlockTree, _blockProducer, _api.LogManager),
                    new NewBlockHandler(_api.BlockTree, _api.BlockPreprocessor, _api.BlockchainProcessor, _api.StateProvider, _api.Config <IInitConfig>(), _api.LogManager),
                    new SetHeadBlockHandler(_api.BlockTree, _api.StateProvider, _api.LogManager),
                    new FinaliseBlockHandler(),
                    _api.LogManager);

                _api.RpcModuleProvider.RegisterSingle(consensusRpcModule);
                if (_logger.IsInfo)
                {
                    _logger.Info("Consensus Module has been enabled");
                }
            }
        }