public override int MessageIdSpaceSize => 17; // magic number here following Go public override void HandleMessage(ZeroPacket message) { base.HandleMessage(message); int size = message.Content.ReadableBytes; switch (message.PacketType) { case Eth63MessageCode.GetReceipts: GetReceiptsMessage getReceiptsMessage = Deserialize <GetReceiptsMessage>(message.Content); ReportIn(getReceiptsMessage); Handle(getReceiptsMessage); break; case Eth63MessageCode.Receipts: ReceiptsMessage receiptsMessage = Deserialize <ReceiptsMessage>(message.Content); ReportIn(receiptsMessage); Handle(receiptsMessage, size); break; case Eth63MessageCode.GetNodeData: GetNodeDataMessage getNodeDataMessage = Deserialize <GetNodeDataMessage>(message.Content); ReportIn(getNodeDataMessage); Handle(getNodeDataMessage); break; case Eth63MessageCode.NodeData: NodeDataMessage nodeDataMessage = Deserialize <NodeDataMessage>(message.Content); ReportIn(nodeDataMessage); Handle(nodeDataMessage, size); break; } }
private void Handle(ReceiptsMessage msg, long size) { Metrics.Eth63ReceiptsReceived++; Request <GetReceiptsMessage, TxReceipt[][]> request = _receiptsRequests.Take(); request.ResponseSize = size; request.CompletionSource.SetResult(msg.TxReceipts); }
private void Handle(ReceiptsMessage msg) { var request = _receiptsRequests.Take(); if (IsRequestMatched(request, msg)) { request.CompletionSource.SetResult(msg.TransactionReceipts); } }
private void Handle(ReceiptsMessage msg, long size) { var request = _receiptsRequests.Take(); if (IsRequestMatched(request, msg)) { request.ResponseSize = size; request.CompletionSource.SetResult(msg.TxReceipts); } }
private void Handle(ReceiptsMessage msg, long size) { Metrics.Eth63ReceiptsReceived++; using CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); cancellationTokenSource.CancelAfter(1000); Request <GetReceiptsMessage, TxReceipt[][]> request = _receiptsRequests.Take(cancellationTokenSource.Token); request.ResponseSize = size; request.CompletionSource.SetResult(msg.TxReceipts); }
private bool IsRequestMatched( Request <GetReceiptsMessage, TxReceipt[][]> request, ReceiptsMessage response) { return(response.PacketType == Eth63MessageCode.Receipts); // TODO: more detailed }
private void Handle(ReceiptsMessage msg, long size) { Metrics.Eth63ReceiptsReceived++; _receiptsRequests.Handle(msg.TxReceipts, size); }
protected virtual void Handle(ReceiptsMessage msg, long size) { Metrics.Eth63ReceiptsReceived++; _receiptsRequests.Handle(msg.TxReceipts, size); }