Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Fix Bloom migration (#9992)
Browse files Browse the repository at this point in the history
* Fix wrong block number in blooms migration

* Fix wrong `const` type (usize -> u64) 😬
  • Loading branch information
ngotchac authored and 5chdn committed Nov 30, 2018
1 parent 3d73937 commit ac9fcb4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions parity/db/rocksdb/blooms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P: AsRef<Path>>(path: P, config: &DatabaseConfig) -> Result<(), Error> {
// init
let db = open_database(&path.as_ref().to_string_lossy(), config)?;
Expand All @@ -41,11 +43,12 @@ pub fn migrate_blooms<P: AsRef<Path>>(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::<Bloom>(&group);
(number, blooms)
Expand All @@ -66,11 +69,12 @@ pub fn migrate_blooms<P: AsRef<Path>>(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::<Bloom>(&group);
(number, blooms)
Expand Down

0 comments on commit ac9fcb4

Please sign in to comment.