Пример #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);
        }
        private static HiMessage Deserialize(Rlp.DecoderContext context)
        {
            context.ReadSequenceLength();
            var protocolVersion = context.DecodeByte();
            var providerAddress = context.DecodeAddress();
            var consumerAddress = context.DecodeAddress();
            var nodeId          = new PublicKey(context.DecodeByteArray());
            var signature       = SignatureDecoder.DecodeSignature(context);

            return(new HiMessage(protocolVersion, providerAddress, consumerAddress,
                                 nodeId, signature));
        }
Пример #3
0
        private List <Vote> DecodeVotes(Rlp.DecoderContext context)
        {
            context.ReadSequenceLength();
            List <Vote> votes  = new List <Vote>();
            int         length = context.DecodeInt();

            for (int i = 0; i < length; i++)
            {
                Address signer    = context.DecodeAddress();
                UInt256 block     = context.DecodeUInt256();
                Address address   = context.DecodeAddress();
                bool    authorize = context.DecodeBool();
                Vote    vote      = new Vote(signer, block, address, authorize);
                votes.Add(vote);
            }
            return(votes);
        }
Пример #4
0
        private SortedList <Address, UInt256> DecodeSigners(Rlp.DecoderContext context)
        {
            context.ReadSequenceLength();
            SortedList <Address, UInt256> signers = new SortedList <Address, UInt256>(CliqueAddressComparer.Instance);
            int length = context.DecodeInt();

            for (int i = 0; i < length; i++)
            {
                Address signer   = context.DecodeAddress();
                UInt256 signedAt = context.DecodeUInt256();
                signers.Add(signer, signedAt);
            }

            return(signers);
        }
Пример #5
0
        private Dictionary <Address, Tally> DecodeTally(Rlp.DecoderContext context)
        {
            context.ReadSequenceLength();
            Dictionary <Address, Tally> tally = new Dictionary <Address, Tally>();
            int length = context.DecodeInt();

            for (int i = 0; i < length; i++)
            {
                Address address   = context.DecodeAddress();
                int     votes     = context.DecodeInt();
                bool    authorize = context.DecodeBool();
                Tally   tallyItem = new Tally(authorize);
                tallyItem.Votes = votes;
                tally[address]  = tallyItem;
            }
            return(tally);
        }
Пример #6
0
        private Dictionary <Address, ParityAccountStateChange> DecodeStateDiff(Rlp.DecoderContext context)
        {
            var accountStateChange = new Dictionary <Address, ParityAccountStateChange>();
            int checkpoint         = context.ReadSequenceLength();
            int items = context.ReadNumberOfItemsRemaining(context.Position + checkpoint);

            if (items == 0)
            {
                return(null);
            }

            for (int i = 0; i < items; i = i + 2)
            {
                accountStateChange[context.DecodeAddress()] = DecodeAccountStateChange(context);
            }

            return(accountStateChange);
        }