示例#1
0
        private static Rlp EncodeChange(ParityAccountStateChange item)
        {
            Rlp[] items = new Rlp[4];
            items[0] = (item.Balance == null ? Rlp.OfEmptySequence : EncodeChange(item.Balance));
            items[1] = (item.Code == null ? Rlp.OfEmptySequence : EncodeChange(item.Code));
            items[2] = (item.Nonce == null ? Rlp.OfEmptySequence : EncodeChange(item.Nonce));
            if (item.Storage == null)
            {
                items[3] = Rlp.OfEmptySequence;
            }
            else
            {
                Rlp[] storageItems = new Rlp[item.Storage.Count * 2];
                int   index        = 0;
                foreach ((UInt256 address, ParityStateChange <byte[]> change) in item.Storage)
                {
                    storageItems[index++] = (Rlp.Encode(address));
                    storageItems[index++] = (EncodeChange(change));
                }

                items[3] = Rlp.Encode(storageItems);
            }

            return(Rlp.Encode(items));
        }
示例#2
0
        private ParityAccountStateChange DecodeAccountStateChange(RlpStream rlpStream)
        {
            rlpStream.ReadSequenceLength();
            ParityAccountStateChange change = new ParityAccountStateChange();

            change.Balance = DecodeChange(rlpStream);
            change.Code    = DecodeByteChange(rlpStream);
            change.Nonce   = DecodeChange(rlpStream);
            change.Storage = DecodeStorageChange(rlpStream);
            return(change);
        }
示例#3
0
        private ParityAccountStateChange DecodeAccountStateChange(Rlp.DecoderContext context)
        {
            context.ReadSequenceLength();
            ParityAccountStateChange change = new ParityAccountStateChange();

            change.Balance = DecodeChange(context);
            change.Code    = DecodeByteChange(context);
            change.Nonce   = DecodeChange(context);
            change.Storage = DecodeStorageChange(context);
            return(change);
        }