From e151fbb0711216b432d52dd70545a25165f4388a Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Mon, 4 Jul 2016 19:05:32 +0200 Subject: [PATCH] fix comments and hash address instead of hash --- ethcore/src/account_db.rs | 2 +- ethcore/src/migrations/state/v7.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ethcore/src/account_db.rs b/ethcore/src/account_db.rs index ee283b495..0d6164aa8 100644 --- a/ethcore/src/account_db.rs +++ b/ethcore/src/account_db.rs @@ -11,7 +11,7 @@ fn combine_key<'a>(address_hash: &'a H256, key: &'a H256) -> H256 { { let last_dst: &mut [u8] = &mut *dst; let last_src: &[u8] = &*address_hash; - for (k, a) in last_dst[8..].iter_mut().zip(&last_src[8..]) { + for (k, a) in last_dst[12..].iter_mut().zip(&last_src[12..]) { *k ^= *a } } diff --git a/ethcore/src/migrations/state/v7.rs b/ethcore/src/migrations/state/v7.rs index cf27c9362..725f1910c 100644 --- a/ethcore/src/migrations/state/v7.rs +++ b/ethcore/src/migrations/state/v7.rs @@ -1,4 +1,4 @@ -use util::hash::{FixedHash, H256}; +use util::hash::{Address, FixedHash, H256}; use util::migration::SimpleMigration; use util::sha3::Hashable; @@ -31,12 +31,14 @@ impl SimpleMigration for ToV7 { return Some((key, value)); } - let address_hash = address.sha3(); + let address_hash = Address::from(address).sha3(); // create the xor'd key in place. key.copy_from_slice(&*val_hash); - let last_dst: &[u8] = &*address_hash; - for (k, a) in key[12..].iter_mut().zip(&last_dst[12..]) { + assert_eq!(key, &*val_hash); + + let last_src: &[u8] = &*address_hash; + for (k, a) in key[12..].iter_mut().zip(&last_src[12..]) { *k ^= *a; } }