From ac9fcb421f3dc9022fe16fa5884518560cda2d27 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Fri, 30 Nov 2018 05:08:20 +0100 Subject: [PATCH] Fix Bloom migration (#9992) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix wrong block number in blooms migration * Fix wrong `const` type (usize -> u64) 😬 --- parity/db/rocksdb/blooms.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/parity/db/rocksdb/blooms.rs b/parity/db/rocksdb/blooms.rs index eba8eb896f7..5c71fe95667 100644 --- a/parity/db/rocksdb/blooms.rs +++ b/parity/db/rocksdb/blooms.rs @@ -23,6 +23,8 @@ use rlp; use super::kvdb_rocksdb::DatabaseConfig; use super::open_database; +const LOG_BLOOMS_ELEMENTS_PER_INDEX: u64 = 16; + pub fn migrate_blooms>(path: P, config: &DatabaseConfig) -> Result<(), Error> { // init let db = open_database(&path.as_ref().to_string_lossy(), config)?; @@ -41,11 +43,12 @@ pub fn migrate_blooms>(path: P, config: &DatabaseConfig) -> Resul key[0] == 3u8 && key[1] == 0u8 }) .map(|(key, group)| { - let number = + let index = (key[2] as u64) << 24 | (key[3] as u64) << 16 | (key[4] as u64) << 8 | (key[5] as u64); + let number = index * LOG_BLOOMS_ELEMENTS_PER_INDEX; let blooms = rlp::decode_list::(&group); (number, blooms) @@ -66,11 +69,12 @@ pub fn migrate_blooms>(path: P, config: &DatabaseConfig) -> Resul key[0] == 1u8 && key[1] == 0u8 }) .map(|(key, group)| { - let number = + let index = (key[2] as u64) | (key[3] as u64) << 8 | (key[4] as u64) << 16 | (key[5] as u64) << 24; + let number = index * LOG_BLOOMS_ELEMENTS_PER_INDEX; let blooms = rlp::decode_list::(&group); (number, blooms)