Exemple #1
0
        private static ParityTraceAction DecodeAction(Rlp.DecoderContext context)
        {
            ParityTraceAction action = new ParityTraceAction();
            int sequenceLength       = context.ReadSequenceLength();

            if (context.ReadNumberOfItemsRemaining(context.Position + sequenceLength) == 3)
            {
                action.CallType     = "reward";
                action.RewardType   = context.DecodeString();
                action.Author       = context.DecodeAddress();
                action.Value        = context.DecodeUInt256();
                action.TraceAddress = Array.Empty <int>();
            }
            else
            {
                action.CallType       = context.DecodeString();
                action.From           = context.DecodeAddress();
                action.To             = context.DecodeAddress();
                action.Value          = context.DecodeUInt256();
                action.Gas            = context.DecodeLong();
                action.Input          = context.DecodeByteArray();
                action.Result         = new ParityTraceResult();
                action.Result.Output  = context.DecodeByteArray();
                action.Result.GasUsed = context.DecodeLong();
                action.TraceAddress   = context.DecodeArray(c => c.DecodeInt());
                int subtracesCount = context.DecodeInt();
                action.Subtraces = new List <ParityTraceAction>(subtracesCount);
                for (int i = 0; i < subtracesCount; i++)
                {
                    action.Subtraces.Add(DecodeAction(context));
                }
            }

            return(action);
        }
Exemple #2
0
        public void Long_negative()
        {
            Rlp  output  = Rlp.Encode(-1L);
            var  context = new Rlp.DecoderContext(output.Bytes);
            long value   = context.DecodeLong();

            Assert.AreEqual(-1L, value);
        }
        public FindNodeMessage Deserialize(byte[] msg)
        {
            var results = PrepareForDeserialization <FindNodeMessage>(msg);

            Rlp.DecoderContext context = results.Data.AsRlpContext();

            context.ReadSequenceLength();
            var searchedNodeId = context.DecodeByteArray();
            var expireTime     = context.DecodeLong();

            var message = results.Message;

            message.SearchedNodeId = searchedNodeId;
            message.ExpirationTime = expireTime;

            return(message);
        }
        public NodeDataFeed(ISnapshotableDb codeDb, ISnapshotableDb stateDb, ILogManager logManager)
        {
            _codeDb  = codeDb ?? throw new ArgumentNullException(nameof(codeDb));
            _stateDb = stateDb ?? throw new ArgumentNullException(nameof(stateDb));
            _logger  = logManager.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager));

            byte[] progress = _codeDb.Get(_fastSyncProgressKey);
            if (progress != null)
            {
                Rlp.DecoderContext context = new Rlp.DecoderContext(progress);
                context.ReadSequenceLength();
                _consumedNodesCount  = context.DecodeLong();
                _savedStorageCount   = context.DecodeLong();
                _savedStateCount     = context.DecodeLong();
                _savedNodesCount     = context.DecodeLong();
                _savedAccounts       = context.DecodeLong();
                _savedCode           = context.DecodeLong();
                _requestedNodesCount = context.DecodeLong();
                _dbChecks            = context.DecodeLong();
                _stateWasThere       = context.DecodeLong();
                _stateWasNotThere    = context.DecodeLong();
                if (context.Position != context.Length)
                {
                    _dataSize = context.DecodeLong();
                }
            }
        }