Пример #1
0
        private void RegisterJsonRpcModules()
        {
            if (!_initConfig.JsonRpcEnabled)
            {
                return;
            }

            if (_logger.IsDebug)
            {
                _logger.Debug($"Resolving CLI ({nameof(Cli.CliModuleLoader)})");
            }

            IReadOnlyDbProvider rpcDbProvider = new ReadOnlyDbProvider(_dbProvider, false);
            AlternativeChain    rpcChain      = new AlternativeChain(_blockTree, _blockValidator, _rewardCalculator, _specProvider, rpcDbProvider, _recoveryStep, _logManager, _txPool, _receiptStorage);

            ITracer        tracer        = new Tracer(rpcChain.Processor, _receiptStorage, new ReadOnlyBlockTree(_blockTree), _dbProvider.TraceDb);
            IFilterStore   filterStore   = new FilterStore();
            IFilterManager filterManager = new FilterManager(filterStore, _blockProcessor, _txPool, _logManager);

            RpcState rpcState = new RpcState(_blockTree, _specProvider, rpcDbProvider, _logManager);

            //creating blockchain bridge
            var blockchainBridge = new BlockchainBridge(
                rpcState.StateReader,
                rpcState.StateProvider,
                rpcState.StorageProvider,
                rpcState.BlockTree,
                _txPool,
                _transactionPoolInfoProvider,
                _receiptStorage,
                filterStore,
                filterManager,
                _wallet,
                rpcState.TransactionProcessor,
                _ethereumEcdsa);

            AlternativeChain    debugChain      = new AlternativeChain(_blockTree, _blockValidator, _rewardCalculator, _specProvider, rpcDbProvider, _recoveryStep, _logManager, NullTxPool.Instance, NullReceiptStorage.Instance);
            IReadOnlyDbProvider debugDbProvider = new ReadOnlyDbProvider(_dbProvider, false);
            var debugBridge = new DebugBridge(_configProvider, debugDbProvider, tracer, debugChain.Processor);

            EthModule module = new EthModule(_logManager, blockchainBridge);

            _rpcModuleProvider.Register <IEthModule>(module);

            DebugModule debugModule = new DebugModule(_logManager, debugBridge);

            _rpcModuleProvider.Register <IDebugModule>(debugModule);

            if (_sealValidator is CliqueSealValidator)
            {
                CliqueModule cliqueModule = new CliqueModule(_logManager, new CliqueBridge(_blockProducer as ICliqueBlockProducer, _snapshotManager, _blockTree));
                _rpcModuleProvider.Register <ICliqueModule>(cliqueModule);
            }

            if (_initConfig.EnableUnsecuredDevWallet)
            {
                PersonalBridge personalBridge = new PersonalBridge(_ethereumEcdsa, _wallet);
                PersonalModule personalModule = new PersonalModule(personalBridge, _logManager);
                _rpcModuleProvider.Register <IPersonalModule>(personalModule);
            }

            AdminModule adminModule = new AdminModule(_logManager, _peerManager, _staticNodesManager);

            _rpcModuleProvider.Register <IAdminModule>(adminModule);

            TxPoolModule txPoolModule = new TxPoolModule(_logManager, blockchainBridge);

            _rpcModuleProvider.Register <ITxPoolModule>(txPoolModule);

            NetModule netModule = new NetModule(_logManager, new NetBridge(_enode, _syncServer, _peerManager));

            _rpcModuleProvider.Register <INetModule>(netModule);

            TraceModule traceModule = new TraceModule(blockchainBridge, _logManager, tracer);

            _rpcModuleProvider.Register <ITraceModule>(traceModule);
        }
Пример #2
0
        private void RegisterJsonRpcModules()
        {
            if (!_initConfig.JsonRpcEnabled)
            {
                return;
            }

            if (_logger.IsDebug)
            {
                _logger.Debug($"Resolving CLI ({nameof(Cli.CliModuleLoader)})");
            }

            IReadOnlyDbProvider rpcDbProvider = new ReadOnlyDbProvider(_dbProvider, false);
            AlternativeChain    rpcChain      = new AlternativeChain(_blockTree, _blockValidator, _rewardCalculator, _specProvider, rpcDbProvider, _recoveryStep, _logManager, _transactionPool, _receiptStorage);

            ITracer        tracer        = new Tracer(rpcChain.Processor, _receiptStorage, _blockTree, _dbProvider.TraceDb);
            IFilterStore   filterStore   = new FilterStore();
            IFilterManager filterManager = new FilterManager(filterStore, _blockProcessor, _transactionPool, _logManager);

            RpcState rpcState = new RpcState(_blockTree, _specProvider, rpcDbProvider, _logManager);

            //creating blockchain bridge
            var blockchainBridge = new BlockchainBridge(
                rpcState.StateReader,
                rpcState.StateProvider,
                rpcState.StorageProvider,
                rpcState.BlockTree,
                _transactionPool,
                _transactionPoolInfoProvider,
                _receiptStorage,
                filterStore,
                filterManager,
                _wallet,
                rpcState.TransactionProcessor);

            TransactionPool debugTransactionPool = new TransactionPool(new PersistentTransactionStorage(_dbProvider.PendingTxsDb, _specProvider),
                                                                       new PendingTransactionThresholdValidator(_initConfig.ObsoletePendingTransactionInterval, _initConfig.RemovePendingTransactionInterval),
                                                                       _timestamp,
                                                                       _ethereumEcdsa,
                                                                       _specProvider,
                                                                       _logManager,
                                                                       _initConfig.RemovePendingTransactionInterval,
                                                                       _initConfig.PeerNotificationThreshold);

            var debugReceiptStorage             = new PersistentReceiptStorage(_dbProvider.ReceiptsDb, _specProvider);
            AlternativeChain    debugChain      = new AlternativeChain(_blockTree, _blockValidator, _rewardCalculator, _specProvider, rpcDbProvider, _recoveryStep, _logManager, debugTransactionPool, debugReceiptStorage);
            IReadOnlyDbProvider debugDbProvider = new ReadOnlyDbProvider(_dbProvider, false);
            var debugBridge = new DebugBridge(_configProvider, debugDbProvider, tracer, debugChain.Processor);

            EthModule module = new EthModule(_jsonSerializer, _configProvider, _logManager, blockchainBridge);

            _rpcModuleProvider.Register <IEthModule>(module);

            DebugModule debugModule = new DebugModule(_configProvider, _logManager, debugBridge, _jsonSerializer);

            _rpcModuleProvider.Register <IDebugModule>(debugModule);

            if (_sealer is CliqueSealer)
            {
                CliqueModule cliqueModule = new CliqueModule(_configProvider, _logManager, _jsonSerializer, new CliqueBridge(_blockProducer as ICliqueBlockProducer, _snapshotManager, _blockTree));
                _rpcModuleProvider.Register <ICliqueModule>(cliqueModule);
            }

            if (_initConfig.EnableUnsecuredDevWallet)
            {
                PersonalBridge personalBridge = new PersonalBridge(_wallet);
                PersonalModule personalModule = new PersonalModule(personalBridge, _configProvider, _logManager, _jsonSerializer);
                _rpcModuleProvider.Register <IPersonalModule>(personalModule);
            }

            AdminModule adminModule = new AdminModule(_configProvider, _logManager, _jsonSerializer);

            _rpcModuleProvider.Register <IAdminModule>(adminModule);

            TxPoolModule txPoolModule = new TxPoolModule(_configProvider, _logManager, _jsonSerializer, blockchainBridge);

            _rpcModuleProvider.Register <ITxPoolModule>(txPoolModule);

            if (_initConfig.NetworkEnabled && _initConfig.SynchronizationEnabled)
            {
                NetModule netModule = new NetModule(_configProvider, _logManager, _jsonSerializer, new NetBridge(_enode, _syncManager, _peerManager));
                _rpcModuleProvider.Register <INetModule>(netModule);
            }

            TraceModule traceModule = new TraceModule(_configProvider, _logManager, _jsonSerializer, tracer);

            _rpcModuleProvider.Register <ITraceModule>(traceModule);
        }
Пример #3
0
        private void RegisterJsonRpcModules()
        {
            if (!_initConfig.JsonRpcEnabled)
            {
                return;
            }

            IReadOnlyDbProvider rpcDbProvider = new ReadOnlyDbProvider(_dbProvider, false);
            AlternativeChain    rpcChain      = new AlternativeChain(_blockTree, _blockValidator, _rewardCalculator, _specProvider, rpcDbProvider, _recoveryStep, _logManager, _transactionPool, _receiptStorage);

            ITracer        tracer        = new Tracer(rpcChain.Processor, _receiptStorage, _blockTree, _dbProvider.TraceDb);
            IFilterStore   filterStore   = new FilterStore();
            IFilterManager filterManager = new FilterManager(filterStore, _blockProcessor, _transactionPool, _logManager);

            _wallet = HiveEnabled ? (IWallet) new HiveWallet() : new DevWallet(_logManager);
            RpcState rpcState = new RpcState(_blockTree, _specProvider, rpcDbProvider, _logManager);

            //creating blockchain bridge
            var blockchainBridge = new BlockchainBridge(
                _ethereumSigner,
                rpcState.StateProvider,
                rpcState.BlockTree,
                _transactionPool,
                _transactionPoolInfoProvider,
                _receiptStorage,
                filterStore,
                filterManager,
                _wallet,
                rpcState.TransactionProcessor);

            TransactionPool debugTransactionPool = new TransactionPool(new PersistentTransactionStorage(_dbProvider.PendingTxsDb, _specProvider),
                                                                       new PendingTransactionThresholdValidator(_initConfig.ObsoletePendingTransactionInterval, _initConfig.RemovePendingTransactionInterval),
                                                                       _timestamp,
                                                                       _ethereumSigner,
                                                                       _logManager,
                                                                       _initConfig.RemovePendingTransactionInterval,
                                                                       _initConfig.PeerNotificationThreshold);

            var debugReceiptStorage             = new PersistentReceiptStorage(_dbProvider.ReceiptsDb, _specProvider);
            AlternativeChain    debugChain      = new AlternativeChain(_blockTree, _blockValidator, _rewardCalculator, _specProvider, rpcDbProvider, _recoveryStep, _logManager, debugTransactionPool, debugReceiptStorage);
            IReadOnlyDbProvider debugDbProvider = new ReadOnlyDbProvider(_dbProvider, false);
            var debugBridge = new DebugBridge(debugDbProvider, tracer, debugChain.Processor);

            JsonRpcModelMapper mapper = new JsonRpcModelMapper();

            EthModule module = new EthModule(_jsonSerializer, _configProvider, mapper, _logManager, blockchainBridge);

            _rpcModuleProvider.Register <IEthModule>(module);

            DebugModule debugModule = new DebugModule(_configProvider, _logManager, debugBridge, mapper, _jsonSerializer);

            _rpcModuleProvider.Register <IDebugModule>(debugModule);

            if (_sealEngine is CliqueSealEngine)
            {
                CliqueModule cliqueModule = new CliqueModule(_configProvider, _logManager, _jsonSerializer, new CliqueBridge(_blockProducer as CliqueBlockProducer, _blockTree));
                _rpcModuleProvider.Register <ICliqueModule>(cliqueModule);
            }

            AdminModule adminModule = new AdminModule(_configProvider, _logManager, _jsonSerializer);

            _rpcModuleProvider.Register <IAdminModule>(adminModule);

            TxPoolModule txPoolModule = new TxPoolModule(_configProvider, _logManager, _jsonSerializer, blockchainBridge, mapper);

            _rpcModuleProvider.Register <ITxPoolModule>(txPoolModule);

            if (_initConfig.NetworkEnabled && _initConfig.SynchronizationEnabled)
            {
                NetModule netModule = new NetModule(_configProvider, _logManager, _jsonSerializer, new NetBridge(_syncManager));
                _rpcModuleProvider.Register <INetModule>(netModule);
            }

            TraceModule traceModule = new TraceModule(_configProvider, _logManager, _jsonSerializer, tracer);

            _rpcModuleProvider.Register <ITraceModule>(traceModule);

            _rpcModuleProvider.Register <INethmModule>(new NethmModule(_configProvider, _logManager, _jsonSerializer, _enode));
        }