Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public BlockInfo Decode(Rlp.DecoderContext context, RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            int lastCheck = context.ReadSequenceLength() + context.Position;

            BlockInfo blockInfo = new BlockInfo();

            blockInfo.BlockHash         = context.DecodeKeccak();
            blockInfo.WasProcessed      = context.DecodeBool();
            blockInfo.TotalDifficulty   = context.DecodeUBigInt();
            blockInfo.TotalTransactions = context.DecodeUBigInt();

            if (!rlpBehaviors.HasFlag(RlpBehaviors.AllowExtraData))
            {
                context.Check(lastCheck);
            }

            return(blockInfo);
        }