public Eth63ProtocolHandler( IP2PSession p2PSession, IMessageSerializationService serializer, ISynchronizationManager sync, ILogManager logManager, IPerfService perfService) : base(p2PSession, serializer, sync, logManager, perfService) { }
protected ProtocolHandlerBase(IP2PSession p2PSession, IMessageSerializationService serializer, ILogManager logManager) { Logger = logManager?.GetClassLogger(GetType()) ?? throw new ArgumentNullException(nameof(logManager)); _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); P2PSession = p2PSession ?? throw new ArgumentNullException(nameof(p2PSession)); _initCompletionSource = new TaskCompletionSource <MessageBase>(); }
public Eth62ProtocolHandler( IP2PSession p2PSession, IMessageSerializationService serializer, ISynchronizationManager sync, ILogManager logManager) : base(p2PSession, serializer, logManager) { _sync = sync; }
public Eth63ProtocolHandler( IP2PSession p2PSession, IMessageSerializationService serializer, ISynchronizationManager syncManager, ILogManager logManager, IPerfService perfService, IBlockTree blockTree, ITransactionPool transactionPool, ITimestamp timestamp) : base(p2PSession, serializer, syncManager, logManager, perfService, blockTree, transactionPool, timestamp) { }
public P2PProtocolHandler( IP2PSession p2PSession, IMessageSerializationService serializer, NodeId localNodeId, int listenPort, ILogManager logManager) : base(p2PSession, serializer, logManager) { LocalNodeId = localNodeId; ListenPort = listenPort; AgreedCapabilities = new List <Capability>(); }
public P2PProtocolHandler( IP2PSession p2PSession, IMessageSerializationService serializer, NodeId localNodeId, int listenPort, ILogManager logManager, IPerfService perfService) : base(p2PSession, serializer, logManager) { _perfService = perfService ?? throw new ArgumentNullException(nameof(perfService)); LocalNodeId = localNodeId; ListenPort = listenPort; AgreedCapabilities = new List <Capability>(); }
public NettyHandshakeHandler( IEncryptionHandshakeService service, IP2PSession p2PSession, EncryptionHandshakeRole role, NodeId remoteId, ILogger logger) { _handshake.RemoteNodeId = remoteId; _role = role; _remoteId = remoteId; _logger = logger; _service = service; _p2PSession = p2PSession; _initCompletionSource = new TaskCompletionSource <object>(); }
public NettyHandshakeHandler( IEncryptionHandshakeService service, IP2PSession p2PSession, HandshakeRole role, NodeId remoteId, ILogManager logManager) { _handshake.RemoteNodeId = remoteId; _role = role; _remoteId = remoteId; _logManager = logManager ?? throw new ArgumentNullException(nameof(NettyHandshakeHandler)); _logger = logManager.GetClassLogger <NettyHandshakeHandler>(); _service = service; _p2PSession = p2PSession; _initCompletionSource = new TaskCompletionSource <object>(); }
public Eth62ProtocolHandler( IP2PSession p2PSession, IMessageSerializationService serializer, ISynchronizationManager syncManager, ILogManager logManager, IPerfService perfService, IBlockTree blockTree, ITransactionPool transactionPool, ITimestamp timestamp) : base(p2PSession, serializer, logManager) { SyncManager = syncManager; _perfService = perfService ?? throw new ArgumentNullException(nameof(perfService)); _blockTree = blockTree; _transactionPool = transactionPool; _timestamp = timestamp; }
public Eth62ProtocolHandler( IP2PSession p2PSession, IMessageSerializationService serializer, ISynchronizationManager syncManager, ILogManager logManager, IPerfService perfService, IBlockTree blockTree, ITransactionPool transactionPool, ITimestamp timestamp) : base(p2PSession, serializer, logManager) { SyncManager = syncManager; _perfService = perfService ?? throw new ArgumentNullException(nameof(perfService)); _blockTree = blockTree; _transactionPool = transactionPool; _timestamp = timestamp; _txFloodCheckTimer = new System.Timers.Timer(_txFloodCheckInterval.TotalMilliseconds); _txFloodCheckTimer.Elapsed += CheckTxFlooding; _txFloodCheckTimer.Start(); }
public NettyP2PHandler(IP2PSession ip2PSession, ILogger logger) { _ip2PSession = ip2PSession; _logger = logger; }
public SessionEventArgs(IP2PSession session) { Session = session; }
public void TriggerSessionCreated(IP2PSession session) { SessionCreated?.Invoke(this, new SessionEventArgs(session)); }
private async Task <bool> ProcessIncomingConnection(IP2PSession session, P2PProtocolHandler protocolHandler) { //if we have already initiated connection before if (_activePeers.ContainsKey(session.RemoteNodeId)) { if (_logger.IsInfoEnabled) { _logger.Info($"Initiating disconnect, node is already connected: {session.RemoteNodeId}"); } await session.InitiateDisconnectAsync(DisconnectReason.AlreadyConnected); return(false); } //if we have too many acive peers if (_activePeers.Count >= _configurationProvider.ActivePeersMaxCount) { if (_logger.IsInfoEnabled) { _logger.Info($"Initiating disconnect, we have too many peers: {session.RemoteNodeId}"); } await session.InitiateDisconnectAsync(DisconnectReason.TooManyPeers); return(false); } //it is possible we already have this node as a candidate if (_candidatePeers.TryGetValue(session.RemoteNodeId, out var peer)) { peer.Session = session; peer.P2PMessageSender = protocolHandler; peer.ClientConnectionType = session.ClientConnectionType; } else { peer = new Peer(_nodeFactory.CreateNode(session.RemoteNodeId, session.RemoteHost, session.RemotePort ?? 0), _nodeStatsProvider.GetNodeStats(session.RemoteNodeId)) { ClientConnectionType = session.ClientConnectionType, Session = session, P2PMessageSender = protocolHandler }; } if (_activePeers.TryAdd(session.RemoteNodeId, peer)) { //add subsripton for disconnect for new active peer //peer.Session.PeerDisconnected += async (s, e) => await OnPeerDisconnected(s, e); //we also add this node to candidates for future connection (if we dont have it yet) _candidatePeers.TryAdd(session.RemoteNodeId, peer); if (_isDiscoveryEnabled && peer.NodeLifecycleManager == null) { //In case peer was initiated outside of discovery and discovery is enabled, we are adding it to discovery for future use var manager = _discoveryManager.GetNodeLifecycleManager(peer.Node); peer.NodeLifecycleManager = manager; } return(true); } //if we have already initiated connection before (threding safeguard - it means another thread added this node to active collection after our contains key key check above) if (_logger.IsInfoEnabled) { _logger.Info($"Initiating disconnect, node is already connected: {session.RemoteNodeId}"); } await session.InitiateDisconnectAsync(DisconnectReason.AlreadyConnected); return(false); }
public ConnectionInitializedEventArgs(IP2PSession session, ClientConnectionType clientConnectionType) { Session = session; ClientConnectionType = clientConnectionType; }
public void TriggerConnectionInitialized(IP2PSession session) { ConnectionInitialized?.Invoke(this, new ConnectionInitializedEventArgs(session)); }
public void TriggerConnectionInitialized(IP2PSession session, ClientConnectionType clientConnectionType = ClientConnectionType.Out) { ConnectionInitialized?.Invoke(this, new ConnectionInitializedEventArgs(session, clientConnectionType)); }
public ConnectionInitializedEventArgs(IP2PSession session, ConnectionDirection connectionDirection) { Session = session; ConnectionDirection = connectionDirection; }