private void Handle(NewBlockHashesMessage newBlockHashes) { Metrics.Eth62NewBlockHashesReceived++; foreach ((Keccak hash, long number) in newBlockHashes.BlockHashes) { SyncServer.HintBlock(hash, number, this); } }
private void Handle(NewBlockHashesMessage newBlockHashes) { Metrics.Eth62NewBlockHashesReceived++; (Keccak, long)[] blockHashes = newBlockHashes.BlockHashes;
public override void HandleMessage(ZeroPacket message) { int packetType = message.PacketType; if (!_statusReceived && packetType != Eth62MessageCode.Status) { throw new SubprotocolException( $"No {nameof(StatusMessage)} received prior to communication with {Node:c}."); } int size = message.Content.ReadableBytes; if (Logger.IsTrace) { Logger.Trace( $"{Counter:D5} {Eth62MessageCode.GetDescription(packetType)} from {Node:c}"); } switch (packetType) { case Eth62MessageCode.Status: StatusMessage statusMsg = Deserialize <StatusMessage>(message.Content); ReportIn(statusMsg); Handle(statusMsg); break; case Eth62MessageCode.NewBlockHashes: NewBlockHashesMessage newBlockHashesMessage = Deserialize <NewBlockHashesMessage>(message.Content); ReportIn(newBlockHashesMessage); Handle(newBlockHashesMessage); break; case Eth62MessageCode.Transactions: Metrics.Eth62TransactionsReceived++; if (_floodController.IsAllowed()) { TransactionsMessage txMsg = Deserialize <TransactionsMessage>(message.Content); ReportIn(txMsg); Handle(txMsg); } break; case Eth62MessageCode.GetBlockHeaders: GetBlockHeadersMessage getBlockHeadersMessage = Deserialize <GetBlockHeadersMessage>(message.Content); ReportIn(getBlockHeadersMessage); Handle(getBlockHeadersMessage); break; case Eth62MessageCode.BlockHeaders: BlockHeadersMessage headersMsg = Deserialize <BlockHeadersMessage>(message.Content); ReportIn(headersMsg); Handle(headersMsg, size); break; case Eth62MessageCode.GetBlockBodies: GetBlockBodiesMessage getBodiesMsg = Deserialize <GetBlockBodiesMessage>(message.Content); ReportIn(getBodiesMsg); Handle(getBodiesMsg); break; case Eth62MessageCode.BlockBodies: HandleBodies(message.Content, size); break; case Eth62MessageCode.NewBlock: NewBlockMessage newBlockMsg = Deserialize <NewBlockMessage>(message.Content); ReportIn(newBlockMsg); Handle(newBlockMsg); break; } }