예제 #1
0
        public void Encode(Account account, RlpStream rlpStream, int?contentLength = null)
        {
            if (contentLength == null)
            {
                contentLength = GetContentLength(account);
            }

            rlpStream.StartSequence(contentLength.Value);
            rlpStream.Encode(account.Nonce);
            rlpStream.Encode(account.Balance);

            if (_slimFormat && !account.HasStorage)
            {
                rlpStream.EncodeEmptyByteArray();
            }
            else
            {
                rlpStream.Encode(account.StorageRoot);
            }

            if (_slimFormat && !account.HasCode)
            {
                rlpStream.EncodeEmptyByteArray();
            }
            else
            {
                rlpStream.Encode(account.CodeHash);
            }
        }