コード例 #1
0
        public override void HandleMessage(ZeroPacket message)
        {
            int size = message.Content.ReadableBytes;

            switch (message.PacketType)
            {
            case SnapMessageCode.GetAccountRange:
                GetAccountRangeMessage getAccountRangeMessage = Deserialize <GetAccountRangeMessage>(message.Content);
                ReportIn(getAccountRangeMessage);
                Handle(getAccountRangeMessage);
                break;

            case SnapMessageCode.AccountRange:
                AccountRangeMessage accountRangeMessage = Deserialize <AccountRangeMessage>(message.Content);
                ReportIn(accountRangeMessage);
                Handle(accountRangeMessage, size);
                break;

            case SnapMessageCode.GetStorageRanges:
                GetStorageRangeMessage getStorageRangesMessage = Deserialize <GetStorageRangeMessage>(message.Content);
                ReportIn(getStorageRangesMessage);
                Handle(getStorageRangesMessage);
                break;

            case SnapMessageCode.StorageRanges:
                StorageRangeMessage storageRangesMessage = Deserialize <StorageRangeMessage>(message.Content);
                ReportIn(storageRangesMessage);
                Handle(storageRangesMessage, size);
                break;

            case SnapMessageCode.GetByteCodes:
                GetByteCodesMessage getByteCodesMessage = Deserialize <GetByteCodesMessage>(message.Content);
                ReportIn(getByteCodesMessage);
                Handle(getByteCodesMessage);
                break;

            case SnapMessageCode.ByteCodes:
                ByteCodesMessage byteCodesMessage = Deserialize <ByteCodesMessage>(message.Content);
                ReportIn(byteCodesMessage);
                Handle(byteCodesMessage, size);
                break;

            case SnapMessageCode.GetTrieNodes:
                GetTrieNodesMessage getTrieNodesMessage = Deserialize <GetTrieNodesMessage>(message.Content);
                ReportIn(getTrieNodesMessage);
                Handle(getTrieNodesMessage);
                break;

            case SnapMessageCode.TrieNodes:
                TrieNodesMessage trieNodesMessage = Deserialize <TrieNodesMessage>(message.Content);
                ReportIn(trieNodesMessage);
                Handle(trieNodesMessage, size);
                break;
            }
        }
コード例 #2
0
        public async Task <byte[][]> GetTrieNodes(AccountsToRefreshRequest request, CancellationToken token)
        {
            PathGroup[] groups = GetPathGroups(request);

            GetTrieNodesMessage reqMsg = new ()
            {
                RootHash = request.RootHash,
                Paths    = groups,
                Bytes    = BYTES_LIMIT
            };

            TrieNodesMessage response = await SendRequest(reqMsg, _getTrieNodesRequests, token);

            Metrics.SnapGetTrieNodesSent++;

            return(response.Nodes);
        }
コード例 #3
0
 private void Handle(TrieNodesMessage msg, long size)
 {
     Metrics.SnapTrieNodesReceived++;
     _getTrieNodesRequests.Handle(msg, size);
 }