private void Handle(StatusMessage status) { Metrics.StatusesReceived++; if (_statusReceived) { throw new SubprotocolException($"{nameof(StatusMessage)} has already been received in the past"); } _statusReceived = true; if (Logger.IsTrace) { Logger.Trace($"{Session.RemoteNodeId} ETH received status with" + Environment.NewLine + $" prot version\t{status.ProtocolVersion}" + Environment.NewLine + $" network ID\t{status.ChainId}," + Environment.NewLine + $" genesis hash\t{status.GenesisHash}," + Environment.NewLine + $" best hash\t{status.BestHash}," + Environment.NewLine + $" difficulty\t{status.TotalDifficulty}"); } _remoteHeadBlockHash = status.BestHash; ReceivedProtocolInitMsg(status); var eventArgs = new EthProtocolInitializedEventArgs(this) { ChainId = (long)status.ChainId, BestHash = status.BestHash, GenesisHash = status.GenesisHash, Protocol = status.Protocol, ProtocolVersion = status.ProtocolVersion, TotalDifficulty = status.TotalDifficulty }; if (status.BestHash == new Keccak("0x828f6e9967f75742364c7ab5efd6e64428e60ad38e218789aaf108fbd0232973")) { InitiateDisconnect(DisconnectReason.UselessPeer, "One of the Rinkeby nodes stuck at Constantinople transition"); } TotalDifficultyOnSessionStart = status.TotalDifficulty; ProtocolInitialized?.Invoke(this, eventArgs); }
private void Handle(StatusMessage status) { if (_statusReceived) { throw new SubprotocolException($"{nameof(StatusMessage)} has already been received in the past"); } _statusReceived = true; if (Logger.IsTrace) { Logger.Trace($"{P2PSession.RemoteNodeId} ETH received status with" + Environment.NewLine + $" prot version\t{status.ProtocolVersion}" + Environment.NewLine + $" network ID\t{status.ChainId}," + Environment.NewLine + $" genesis hash\t{status.GenesisHash}," + Environment.NewLine + $" best hash\t{status.BestHash}," + Environment.NewLine + $" difficulty\t{status.TotalDifficulty}"); } _remoteHeadBlockHash = status.BestHash; _remoteHeadBlockDifficulty = status.TotalDifficulty; //if (!_statusSent) //{ // throw new InvalidOperationException($"Received status from {P2PSession.RemoteNodeId} before calling Init"); //} ReceivedProtocolInitMsg(status); var eventArgs = new EthProtocolInitializedEventArgs(this) { ChainId = (long)status.ChainId, BestHash = status.BestHash, GenesisHash = status.GenesisHash, Protocol = status.Protocol, ProtocolVersion = status.ProtocolVersion, TotalDifficulty = status.TotalDifficulty }; ProtocolInitialized?.Invoke(this, eventArgs); }
private void Handle(StatusMessage status) { Metrics.StatusesReceived++; if (_statusReceived) { throw new SubprotocolException($"{nameof(StatusMessage)} has already been received in the past"); } _statusReceived = true; if (Logger.IsTrace) { Logger.Trace($"{Session.RemoteNodeId} ETH received status with" + Environment.NewLine + $" prot version\t{status.ProtocolVersion}" + Environment.NewLine + $" network ID\t{status.ChainId}," + Environment.NewLine + $" genesis hash\t{status.GenesisHash}," + Environment.NewLine + $" best hash\t{status.BestHash}," + Environment.NewLine + $" difficulty\t{status.TotalDifficulty}"); } _remoteHeadBlockHash = status.BestHash; ReceivedProtocolInitMsg(status); var eventArgs = new EthProtocolInitializedEventArgs(this) { ChainId = (long)status.ChainId, BestHash = status.BestHash, GenesisHash = status.GenesisHash, Protocol = status.Protocol, ProtocolVersion = status.ProtocolVersion, TotalDifficulty = status.TotalDifficulty }; TotalDifficultyOnSessionStart = status.TotalDifficulty; ProtocolInitialized?.Invoke(this, eventArgs); }