Esempio n. 1
0
        public override void HandleMessage(ZeroPacket message)
        {
            int size = message.Content.ReadableBytes;

            switch (message.PacketType)
            {
            case Eth66MessageCode.GetBlockHeaders:
                GetBlockHeadersMessage getBlockHeadersMessage
                    = Deserialize <GetBlockHeadersMessage>(message.Content);
                Metrics.Eth66GetBlockHeadersReceived++;
                ReportIn(getBlockHeadersMessage);
                Handle(getBlockHeadersMessage);
                break;

            case Eth66MessageCode.BlockHeaders:
                BlockHeadersMessage headersMsg = Deserialize <BlockHeadersMessage>(message.Content);
                Metrics.Eth66BlockHeadersReceived++;
                ReportIn(headersMsg);
                Handle(headersMsg.EthMessage, size);
                break;

            case Eth66MessageCode.GetBlockBodies:
                GetBlockBodiesMessage getBodiesMsg = Deserialize <GetBlockBodiesMessage>(message.Content);
                Metrics.Eth66GetBlockBodiesReceived++;
                ReportIn(getBodiesMsg);
                Handle(getBodiesMsg);
                break;

            case Eth66MessageCode.BlockBodies:
                BlockBodiesMessage bodiesMsg = Deserialize <BlockBodiesMessage>(message.Content);
                Metrics.Eth66BlockBodiesReceived++;
                ReportIn(bodiesMsg);
                HandleBodies(bodiesMsg.EthMessage, size);
                break;

            case Eth66MessageCode.GetPooledTransactions:
                GetPooledTransactionsMessage getPooledTxMsg
                    = Deserialize <GetPooledTransactionsMessage>(message.Content);
                Metrics.Eth66GetPooledTransactionsReceived++;
                ReportIn(getPooledTxMsg);
                Handle(getPooledTxMsg);
                break;

            case Eth66MessageCode.PooledTransactions:
                PooledTransactionsMessage pooledTxMsg
                    = Deserialize <PooledTransactionsMessage>(message.Content);
                Metrics.Eth66PooledTransactionsReceived++;
                ReportIn(pooledTxMsg);
                Handle(pooledTxMsg.EthMessage);
                break;

            case Eth66MessageCode.GetReceipts:
                GetReceiptsMessage getReceiptsMessage = Deserialize <GetReceiptsMessage>(message.Content);
                Metrics.Eth66GetReceiptsReceived++;
                ReportIn(getReceiptsMessage);
                Handle(getReceiptsMessage);
                break;

            case Eth66MessageCode.Receipts:
                ReceiptsMessage receiptsMessage = Deserialize <ReceiptsMessage>(message.Content);
                Metrics.Eth66ReceiptsReceived++;
                ReportIn(receiptsMessage);
                Handle(receiptsMessage.EthMessage, size);
                break;

            case Eth66MessageCode.GetNodeData:
                GetNodeDataMessage getNodeDataMessage = Deserialize <GetNodeDataMessage>(message.Content);
                Metrics.Eth66GetNodeDataReceived++;
                ReportIn(getNodeDataMessage);
                Handle(getNodeDataMessage);
                break;

            case Eth66MessageCode.NodeData:
                NodeDataMessage nodeDataMessage = Deserialize <NodeDataMessage>(message.Content);
                Metrics.Eth66NodeDataReceived++;
                ReportIn(nodeDataMessage);
                Handle(nodeDataMessage.EthMessage, size);
                break;

            default:
                base.HandleMessage(message);
                break;
            }
        }
Esempio n. 2
0
 private void Handle(GetPooledTransactionsMessage getPooledTransactions)
 {
     V65.Messages.PooledTransactionsMessage pooledTransactionsMessage =
         FulfillPooledTransactionsRequest(getPooledTransactions.EthMessage);
     Send(new PooledTransactionsMessage(getPooledTransactions.RequestId, pooledTransactionsMessage));
 }