예제 #1
0
        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);
        }
예제 #3
0
        private void Handle(ReceiptsMessage msg)
        {
            var request = _receiptsRequests.Take();

            if (IsRequestMatched(request, msg))
            {
                request.CompletionSource.SetResult(msg.TransactionReceipts);
            }
        }
예제 #4
0
        private void Handle(ReceiptsMessage msg, long size)
        {
            var request = _receiptsRequests.Take();

            if (IsRequestMatched(request, msg))
            {
                request.ResponseSize = size;
                request.CompletionSource.SetResult(msg.TxReceipts);
            }
        }
예제 #5
0
        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);
        }
예제 #6
0
 private bool IsRequestMatched(
     Request <GetReceiptsMessage, TxReceipt[][]> request,
     ReceiptsMessage response)
 {
     return(response.PacketType == Eth63MessageCode.Receipts); // TODO: more detailed
 }
예제 #7
0
 private void Handle(ReceiptsMessage msg, long size)
 {
     Metrics.Eth63ReceiptsReceived++;
     _receiptsRequests.Handle(msg.TxReceipts, size);
 }
예제 #8
0
 protected virtual void Handle(ReceiptsMessage msg, long size)
 {
     Metrics.Eth63ReceiptsReceived++;
     _receiptsRequests.Handle(msg.TxReceipts, size);
 }