Пример #1
0
        public virtual async Task<INdmCapabilityConnector> InitAsync(IConfigProvider configProvider,
            IDbProvider dbProvider, string baseDbPath, IBlockTree blockTree,
            ITxPool txPool, ISpecProvider specProvider, IReceiptStorage receiptStorage, IWallet wallet,
            IFilterStore filterStore, IFilterManager filterManager,
            ITimestamper timestamper, IEthereumEcdsa ecdsa, IRpcModuleProvider rpcModuleProvider, IKeyStore keyStore,
            IJsonSerializer jsonSerializer, ICryptoRandom cryptoRandom, IEnode enode,
            INdmConsumerChannelManager consumerChannelManager, INdmDataPublisher dataPublisher, IGrpcServer grpcServer,
            INodeStatsManager nodeStatsManager, IProtocolsManager protocolsManager,
            IProtocolValidator protocolValidator, IMessageSerializationService messageSerializationService,
            bool enableUnsecuredDevWallet, IWebSocketsManager webSocketsManager, ILogManager logManager,
            IBlockProcessor blockProcessor)
        {
            var (config, services, faucet, accountService, consumerService, consumerAddress, providerAddress) =
                await PreInitAsync(configProvider, dbProvider, baseDbPath, blockTree, txPool, specProvider,
                    receiptStorage, wallet, filterStore, filterManager, timestamper, ecdsa, rpcModuleProvider, keyStore,
                    jsonSerializer, cryptoRandom, enode, consumerChannelManager, dataPublisher, grpcServer,
                    enableUnsecuredDevWallet, webSocketsManager, logManager, blockProcessor);
            if (!config.Enabled)
            {
                return default;
            }

            var subprotocolFactory = new NdmSubprotocolFactory(messageSerializationService, nodeStatsManager,
                logManager, accountService, consumerService, consumerChannelManager, ecdsa, wallet, faucet,
                enode.PublicKey, providerAddress, consumerAddress, config.VerifyP2PSignature);
            var protocolHandlerFactory = new ProtocolHandlerFactory(subprotocolFactory, protocolValidator,
                services.RequiredServices.EthRequestService, logManager);
            var capabilityConnector = new NdmCapabilityConnector(protocolsManager, protocolHandlerFactory,
                accountService, logManager);

            return capabilityConnector;
        }
Пример #2
0
        public virtual async Task <INdmCapabilityConnector> InitAsync(INdmApi api)
        {
            _logger = api.LogManager.GetClassLogger() ?? throw new ArgumentNullException(nameof(api.LogManager));
            INdmConfig ndmConfig = api.Config <INdmConfig>();

            if (!ndmConfig.Enabled)
            {
                // can we not even call it here? // can be step and use the subsystems
                return(NullNdmCapabilityConnector.Instance);
            }

            await PreInitAsync(api);

            NdmSubprotocolFactory subprotocolFactory = new NdmSubprotocolFactory(
                api.MessageSerializationService,
                api.NodeStatsManager,
                api.LogManager,
                api.AccountService,
                api.ConsumerService,
                api.NdmConsumerChannelManager,
                api.EthereumEcdsa,
                api.Wallet,
                api.NdmFaucet,
                api.Enode.PublicKey,
                api.ProviderAddress,
                api.ConsumerAddress,
                api.Config <INdmConfig>().VerifyP2PSignature);

            ProtocolHandlerFactory protocolHandlerFactory = new ProtocolHandlerFactory(
                subprotocolFactory,
                api.ProtocolValidator,
                api.EthRequestService,
                api.LogManager);

            NdmCapabilityConnector capabilityConnector = new NdmCapabilityConnector(
                api.ProtocolsManager,
                protocolHandlerFactory,
                api.AccountService,
                api.LogManager,
                ndmConfig.ProviderAddress == null ? Address.Zero : new Address(ndmConfig.ProviderAddress));

            return(capabilityConnector);
        }
Пример #3
0
        public virtual async Task <INdmCapabilityConnector> InitAsync(
            IConfigProvider configProvider,
            IDbProvider dbProvider,
            string baseDbPath,
            IBlockTree blockTree,
            ITxPool txPool,
            ITxSender txSender,
            ISpecProvider specProvider,
            IReceiptFinder receiptFinder,
            IWallet wallet,
            IFilterStore filterStore,
            IFilterManager filterManager,
            ITimestamper timestamper,
            IEthereumEcdsa ecdsa,
            IRpcModuleProvider rpcModuleProvider,
            IKeyStore keyStore,
            IJsonSerializer jsonSerializer,
            ICryptoRandom cryptoRandom,
            IEnode enode,
            INdmConsumerChannelManager consumerChannelManager,
            INdmDataPublisher dataPublisher,
            IGrpcServer grpcServer,
            INodeStatsManager nodeStatsManager,
            IProtocolsManager protocolsManager,
            IProtocolValidator protocolValidator,
            IMessageSerializationService messageSerializationService,
            bool enableUnsecuredDevWallet,
            IWebSocketsManager webSocketsManager,
            ILogManager logManager,
            IBlockProcessor blockProcessor,
            IJsonRpcClientProxy?jsonRpcClientProxy,
            IEthJsonRpcClientProxy?ethJsonRpcClientProxy,
            IHttpClient httpClient,
            IMonitoringService monitoringService,
            IBloomStorage bloomStorage)
        {
            _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager));
            INdmConfig ndmConfig = configProvider.GetConfig <INdmConfig>();

            if (!ndmConfig.Enabled)
            {
                // can we not even call it here? // can be step and use the subsystems
                return(NullNdmCapabilityConnector.Instance);
            }

            (NdmConfig config, INdmServices services, INdmFaucet faucet, IEthRequestService ethRequestService, IAccountService accountService, IConsumerService consumerService, Address consumerAddress, Address providerAddress) = await PreInitAsync(
                configProvider,
                dbProvider,
                baseDbPath,
                blockTree,
                txPool,
                txSender,
                specProvider,
                receiptFinder,
                wallet,
                filterStore,
                filterManager,
                timestamper,
                ecdsa,
                rpcModuleProvider,
                keyStore,
                jsonSerializer,
                cryptoRandom,
                enode,
                consumerChannelManager,
                dataPublisher,
                grpcServer,
                enableUnsecuredDevWallet,
                webSocketsManager,
                logManager,
                blockProcessor,
                jsonRpcClientProxy,
                ethJsonRpcClientProxy,
                httpClient,
                monitoringService,
                bloomStorage);

            NdmSubprotocolFactory subprotocolFactory = new NdmSubprotocolFactory(messageSerializationService, nodeStatsManager,
                                                                                 logManager, accountService, consumerService, consumerChannelManager, ecdsa, wallet, faucet,
                                                                                 enode.PublicKey, providerAddress, consumerAddress, config.VerifyP2PSignature);
            ProtocolHandlerFactory protocolHandlerFactory = new ProtocolHandlerFactory(subprotocolFactory, protocolValidator,
                                                                                       ethRequestService, logManager);

            NdmCapabilityConnector capabilityConnector = new NdmCapabilityConnector(
                protocolsManager,
                protocolHandlerFactory,
                accountService,
                logManager,
                ndmConfig.ProviderAddress == null ? Address.Zero : new Address(ndmConfig.ProviderAddress));

            return(capabilityConnector);
        }