From 835b158069d0b0daaf0fbd61277ac6520825fafa Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Mon, 13 Jun 2016 21:05:06 +0200 Subject: [PATCH] store account code if it exists --- ethcore/src/snapshot/mod.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ethcore/src/snapshot/mod.rs b/ethcore/src/snapshot/mod.rs index 327ad798c..5d8e6ddcc 100644 --- a/ethcore/src/snapshot/mod.rs +++ b/ethcore/src/snapshot/mod.rs @@ -33,8 +33,7 @@ use views::BlockView; use util::{Bytes, Hashable, HashDB, TrieDB}; use util::hash::{FixedHash, H256}; use util::numbers::U256; -use util::rlp::{DecoderError, Stream, Rlp, RlpStream, UntrustedRlp, View}; - +use util::rlp::{DecoderError, Rlp, RlpStream, Stream, SHA3_NULL_RLP, UntrustedRlp, View}; /// Used to build block chunks. struct BlockChunker<'a> { client: &'a BlockChainClient, @@ -269,9 +268,17 @@ impl AccountReader { let mut account_stream = RlpStream::new_list(5); account_stream.append(&self.nonce) .append(&self.balance) - .append(&self.storage_root) - .append(&self.code_hash) - .append(&pairs_rlp); + .append(&self.storage_root); + + account_stream.begin_list(2); + if self.code_hash == SHA3_NULL_RLP { + account_stream.append(&true).append(&hash_db.get(&self.code_hash).unwrap()); + } else { + let empty: &[u8] = &[]; + account_stream.append(&false).append(&empty); + } + + account_stream.append(&pairs_rlp); Ok(account_stream.out()) }