public void Handle(GetHelperTrieProofsMessage getHelperTrieProofs) { List <byte[]> proofNodes = new List <byte[]>(); List <byte[]> auxData = new List <byte[]>(); for (int requestNo = 0; requestNo < getHelperTrieProofs.Requests.Length; requestNo++) { var request = getHelperTrieProofs.Requests[requestNo]; switch (request.SubType) { case HelperTrieType.CHT: GetCHTData(request, proofNodes, auxData); break; case HelperTrieType.BloomBits: throw new SubprotocolException("bloom bits trie not yet supported"); } } Send(new HelperTrieProofsMessage(proofNodes.Distinct().ToArray(), auxData.ToArray(), getHelperTrieProofs.RequestId, int.MaxValue)); }
public override void HandleMessage(ZeroPacket message) { if (message.PacketType != LesMessageCode.Status && !_statusReceived) { throw new SubprotocolException($"No {nameof(StatusMessage)} received prior to communication with {Session.Node:c}."); } int size = message.Content.ReadableBytes; switch (message.PacketType) { case LesMessageCode.Status: StatusMessage statusMessage = Deserialize <StatusMessage>(message.Content); if (NetworkDiagTracer.IsEnabled) { NetworkDiagTracer.ReportIncomingMessage(Session.Node.Address, Name, statusMessage.ToString()); } Handle(statusMessage); break; case LesMessageCode.GetBlockHeaders: GetBlockHeadersMessage getBlockHeadersMessage = Deserialize <GetBlockHeadersMessage>(message.Content); if (NetworkDiagTracer.IsEnabled) { NetworkDiagTracer.ReportIncomingMessage(Session.Node.Address, Name, getBlockHeadersMessage.ToString()); } Handle(getBlockHeadersMessage); break; case LesMessageCode.GetBlockBodies: GetBlockBodiesMessage getBlockBodiesMessage = Deserialize <GetBlockBodiesMessage>(message.Content); if (NetworkDiagTracer.IsEnabled) { NetworkDiagTracer.ReportIncomingMessage(Session.Node.Address, Name, getBlockBodiesMessage.ToString()); } Handle(getBlockBodiesMessage); break; case LesMessageCode.GetReceipts: GetReceiptsMessage getReceiptsMessage = Deserialize <GetReceiptsMessage>(message.Content); if (NetworkDiagTracer.IsEnabled) { NetworkDiagTracer.ReportIncomingMessage(Session.Node.Address, Name, getReceiptsMessage.ToString()); } Handle(getReceiptsMessage); break; case LesMessageCode.GetContractCodes: GetContractCodesMessage getContractCodesMessage = Deserialize <GetContractCodesMessage>(message.Content); if (NetworkDiagTracer.IsEnabled) { NetworkDiagTracer.ReportIncomingMessage(Session.Node.Address, Name, getContractCodesMessage.ToString()); } Handle(getContractCodesMessage); break; case LesMessageCode.GetHelperTrieProofs: GetHelperTrieProofsMessage getHelperTrieProofsMessage = Deserialize <GetHelperTrieProofsMessage>(message.Content); if (NetworkDiagTracer.IsEnabled) { NetworkDiagTracer.ReportIncomingMessage(Session.Node.Address, Name, getHelperTrieProofsMessage.ToString()); } Handle(getHelperTrieProofsMessage); break; } }