private async Task InitPeer() { /* rlpx */ var eciesCipher = new EciesCipher(_cryptoRandom); var eip8Pad = new Eip8MessagePad(_cryptoRandom); _messageSerializationService.Register(new AuthEip8MessageSerializer(eip8Pad)); _messageSerializationService.Register(new AckEip8MessageSerializer(eip8Pad)); _messageSerializationService.Register(Assembly.GetAssembly(typeof(HelloMessageSerializer))); var encryptionHandshakeServiceA = new EncryptionHandshakeService(_messageSerializationService, eciesCipher, _cryptoRandom, new Ecdsa(), _nodeKey, _logManager); var networkConfig = _configProvider.GetConfig <INetworkConfig>(); _sessionMonitor = new SessionMonitor(networkConfig, _logManager); _rlpxPeer = new RlpxPeer( _nodeKey.PublicKey, _initConfig.P2PPort, encryptionHandshakeServiceA, _logManager, _sessionMonitor); await _rlpxPeer.Init(); var peerStorage = new NetworkStorage(PeersDbPath, networkConfig, _logManager, _perfService); ProtocolValidator protocolValidator = new ProtocolValidator(_nodeStatsManager, _blockTree, _logManager); _protocolsManager = new ProtocolsManager(_syncPeerPool, _syncServer, _txPool, _discoveryApp, _messageSerializationService, _rlpxPeer, _nodeStatsManager, protocolValidator, peerStorage, _perfService, _logManager); PeerLoader peerLoader = new PeerLoader(networkConfig, _nodeStatsManager, peerStorage, _logManager); _peerManager = new PeerManager(_rlpxPeer, _discoveryApp, _nodeStatsManager, peerStorage, peerLoader, networkConfig, _logManager); _peerManager.Init(); }
private async Task InitPeer() { /* rlpx */ var eciesCipher = new EciesCipher(_cryptoRandom); var eip8Pad = new Eip8MessagePad(_cryptoRandom); _messageSerializationService.Register(new AuthEip8MessageSerializer(eip8Pad)); _messageSerializationService.Register(new AckEip8MessageSerializer(eip8Pad)); var encryptionHandshakeServiceA = new EncryptionHandshakeService(_messageSerializationService, eciesCipher, _cryptoRandom, new Signer(), _nodeKey, _logManager); /* p2p */ _messageSerializationService.Register(new HelloMessageSerializer()); _messageSerializationService.Register(new DisconnectMessageSerializer()); _messageSerializationService.Register(new PingMessageSerializer()); _messageSerializationService.Register(new PongMessageSerializer()); /* eth62 */ _messageSerializationService.Register(new StatusMessageSerializer()); _messageSerializationService.Register(new TransactionsMessageSerializer()); _messageSerializationService.Register(new GetBlockHeadersMessageSerializer()); _messageSerializationService.Register(new NewBlockHashesMessageSerializer()); _messageSerializationService.Register(new GetBlockBodiesMessageSerializer()); _messageSerializationService.Register(new BlockHeadersMessageSerializer()); _messageSerializationService.Register(new BlockBodiesMessageSerializer()); _messageSerializationService.Register(new NewBlockMessageSerializer()); /* eth63 */ _messageSerializationService.Register(new GetNodeDataMessageSerializer()); _messageSerializationService.Register(new NodeDataMessageSerializer()); _messageSerializationService.Register(new GetReceiptsMessageSerializer()); _messageSerializationService.Register(new ReceiptsMessageSerializer()); var networkConfig = _configProvider.GetConfig <INetworkConfig>(); ISessionMonitor sessionMonitor = new SessionMonitor(networkConfig, _logManager); _rlpxPeer = new RlpxPeer( _nodeKey.PublicKey, _initConfig.P2PPort, encryptionHandshakeServiceA, _logManager, _perfService, sessionMonitor); await _rlpxPeer.Init(); var peerStorage = new NetworkStorage(PeersDbPath, networkConfig, _logManager, _perfService); ProtocolValidator protocolValidator = new ProtocolValidator(_nodeStatsManager, _blockTree, _logManager); _protocolsManager = new ProtocolsManager(_syncManager, _transactionPool, _discoveryApp, _messageSerializationService, _rlpxPeer, _nodeStatsManager, protocolValidator, peerStorage, _perfService, _logManager); PeerLoader peerLoader = new PeerLoader(networkConfig, _nodeStatsManager, peerStorage, _logManager); _peerManager = new PeerManager(_rlpxPeer, _discoveryApp, _nodeStatsManager, peerStorage, peerLoader, networkConfig, _logManager); _peerManager.Init(); }
private async Task InitPeer() { /* rlpx */ var eciesCipher = new EciesCipher(_cryptoRandom); var eip8Pad = new Eip8MessagePad(_cryptoRandom); _messageSerializationService.Register(new AuthEip8MessageSerializer(eip8Pad)); _messageSerializationService.Register(new AckEip8MessageSerializer(eip8Pad)); var encryptionHandshakeServiceA = new EncryptionHandshakeService(_messageSerializationService, eciesCipher, _cryptoRandom, new Signer(), _privateKey, _logManager); /* p2p */ _messageSerializationService.Register(new HelloMessageSerializer()); _messageSerializationService.Register(new DisconnectMessageSerializer()); _messageSerializationService.Register(new PingMessageSerializer()); _messageSerializationService.Register(new PongMessageSerializer()); /* eth */ _messageSerializationService.Register(new StatusMessageSerializer()); _messageSerializationService.Register(new TransactionsMessageSerializer()); _messageSerializationService.Register(new GetBlockHeadersMessageSerializer()); _messageSerializationService.Register(new NewBlockHashesMessageSerializer()); _messageSerializationService.Register(new GetBlockBodiesMessageSerializer()); _messageSerializationService.Register(new BlockHeadersMessageSerializer()); _messageSerializationService.Register(new BlockBodiesMessageSerializer()); _messageSerializationService.Register(new NewBlockMessageSerializer()); _rlpxPeer = new RlpxPeer(new NodeId(_privateKey.PublicKey), _initConfig.P2PPort, _syncManager, _messageSerializationService, encryptionHandshakeServiceA, _nodeStatsProvider, _logManager, _perfService); await _rlpxPeer.Init(); var peerStorage = new NetworkStorage(PeersDbPath, _configProvider.GetConfig <INetworkConfig>(), _logManager, _perfService); _peerManager = new PeerManager(_rlpxPeer, _discoveryManager, _syncManager, _nodeStatsProvider, peerStorage, _nodeFactory, _configProvider, _perfService, _logManager); _peerManager.Init(_initConfig.DiscoveryEnabled); }
private async Task InitNet(int listenPort) { /* tools */ _messageSerializationService = new MessageSerializationService(); _cryptoRandom = new CryptoRandom(); _signer = new Signer(); /* rlpx */ var eciesCipher = new EciesCipher(_cryptoRandom); var eip8Pad = new Eip8MessagePad(_cryptoRandom); _messageSerializationService.Register(new AuthEip8MessageSerializer(eip8Pad)); _messageSerializationService.Register(new AckEip8MessageSerializer(eip8Pad)); var encryptionHandshakeServiceA = new EncryptionHandshakeService(_messageSerializationService, eciesCipher, _cryptoRandom, _signer, _privateKey, _logManager); /* p2p */ _messageSerializationService.Register(new HelloMessageSerializer()); _messageSerializationService.Register(new DisconnectMessageSerializer()); _messageSerializationService.Register(new PingMessageSerializer()); _messageSerializationService.Register(new PongMessageSerializer()); /* eth */ _messageSerializationService.Register(new StatusMessageSerializer()); _messageSerializationService.Register(new TransactionsMessageSerializer()); _messageSerializationService.Register(new GetBlockHeadersMessageSerializer()); _messageSerializationService.Register(new NewBlockHashesMessageSerializer()); _messageSerializationService.Register(new GetBlockBodiesMessageSerializer()); _messageSerializationService.Register(new BlockHeadersMessageSerializer()); _messageSerializationService.Register(new BlockBodiesMessageSerializer()); _messageSerializationService.Register(new NewBlockMessageSerializer()); _logger.Info("Initializing server..."); _localPeer = new RlpxPeer(new NodeId(_privateKey.PublicKey), listenPort, encryptionHandshakeServiceA, _messageSerializationService, _syncManager, _logManager); await _localPeer.Init(); var localIp = _networkHelper.GetLocalIp(); _logger.Info($"Node is up and listening on {localIp}:{listenPort}... press ENTER to exit"); _logger.Info($"enode://{_privateKey.PublicKey}@{localIp}:{listenPort}"); }
private async Task InitPeer() { /* rlpx */ var eciesCipher = new EciesCipher(_cryptoRandom); var eip8Pad = new Eip8MessagePad(_cryptoRandom); _messageSerializationService.Register(new AuthEip8MessageSerializer(eip8Pad)); _messageSerializationService.Register(new AckEip8MessageSerializer(eip8Pad)); _messageSerializationService.Register(Assembly.GetAssembly(typeof(HelloMessageSerializer))); var encryptionHandshakeServiceA = new EncryptionHandshakeService(_messageSerializationService, eciesCipher, _cryptoRandom, new Ecdsa(), _nodeKey, _logManager); _messageSerializationService.Register(Assembly.GetAssembly(typeof(HiMessageSerializer))); var networkConfig = _configProvider.GetConfig <INetworkConfig>(); var discoveryConfig = _configProvider.GetConfig <IDiscoveryConfig>(); _sessionMonitor = new SessionMonitor(networkConfig, _logManager); _rlpxPeer = new RlpxPeer( _nodeKey.PublicKey, _initConfig.P2PPort, encryptionHandshakeServiceA, _logManager, _sessionMonitor); await _rlpxPeer.Init(); _staticNodesManager = new StaticNodesManager(_initConfig.StaticNodesPath, _logManager); await _staticNodesManager.InitAsync(); var peersDb = new SimpleFilePublicKeyDb(Path.Combine(_initConfig.BaseDbPath, PeersDbPath), _logManager); var peerStorage = new NetworkStorage(peersDb, _logManager); ProtocolValidator protocolValidator = new ProtocolValidator(_nodeStatsManager, _blockTree, _logManager); _protocolsManager = new ProtocolsManager(_syncPeerPool, _syncServer, _txPool, _discoveryApp, _messageSerializationService, _rlpxPeer, _nodeStatsManager, protocolValidator, peerStorage, _perfService, _logManager); if (!(_ndmInitializer is null)) { if (_logger.IsInfo) { _logger.Info($"Initializing NDM..."); } var capabilityConnector = await _ndmInitializer.InitAsync(_configProvider, _dbProvider, _initConfig.BaseDbPath, _blockProcessor, _blockTree, _txPool, _txPoolInfoProvider, _specProvider, _receiptStorage, _wallet, _timestamp, _ethereumEcdsa, _rpcModuleProvider, _keyStore, _jsonSerializer, _cryptoRandom, _enode, _ndmConsumerChannelManager, _ndmDataPublisher, _grpcService, _nodeStatsManager, _protocolsManager, protocolValidator, _messageSerializationService, _initConfig.EnableUnsecuredDevWallet, _logManager); capabilityConnector.Init(); if (_logger.IsInfo) { _logger.Info($"NDM initialized."); } } PeerLoader peerLoader = new PeerLoader(networkConfig, discoveryConfig, _nodeStatsManager, peerStorage, _logManager); _peerManager = new PeerManager(_rlpxPeer, _discoveryApp, _nodeStatsManager, peerStorage, peerLoader, networkConfig, _logManager, _staticNodesManager); _peerManager.Init(); }