diff --git a/node/src/chain.rs b/node/src/chain.rs index be912a6177..7971cb8133 100644 --- a/node/src/chain.rs +++ b/node/src/chain.rs @@ -259,10 +259,10 @@ impl ChainSrv { let genesis_blk = genesis::generate_state(state); db.write().await.update(|t| { // Persist genesis block - t.store_block(genesis_blk.header(), &[], Label::Final) + t.store_block(genesis_blk.header(), &[], Label::Final(0)) })?; - BlockWithLabel::new_with_label(genesis_blk, Label::Final) + BlockWithLabel::new_with_label(genesis_blk, Label::Final(0)) } }; diff --git a/node/src/chain/acceptor.rs b/node/src/chain/acceptor.rs index 3953326840..9cfe05d1ae 100644 --- a/node/src/chain/acceptor.rs +++ b/node/src/chain/acceptor.rs @@ -758,7 +758,7 @@ impl Acceptor { let prev_height = tip.inner().header().height - 1; for height in (0..prev_height).rev() { - if let Ok(Some((hash, Label::Final))) = + if let Ok(Some((hash, Label::Final(_)))) = v.fetch_block_label_by_height(height) { if let Some(blk) = v.fetch_block(&hash)? { diff --git a/node/src/database/rocksdb.rs b/node/src/database/rocksdb.rs index c5b0a1edc0..7f18ea2d76 100644 --- a/node/src/database/rocksdb.rs +++ b/node/src/database/rocksdb.rs @@ -443,13 +443,14 @@ impl<'db, DB: DBAccess> Ledger for DBTransaction<'db, DB> { Ok(self .snapshot .get_cf(self.ledger_height_cf, height.to_le_bytes())? - .filter(|v| v.len() == HASH_LEN + 1) .map(|h| { let mut hash = [0u8; HASH_LEN]; hash.copy_from_slice(&h.as_slice()[0..HASH_LEN]); - let label = Label::from(h[HASH_LEN]); - (hash, label) - })) + + let label_buff = h[HASH_LEN..].to_vec(); + Label::read(&mut &label_buff[..]).map(|label| (hash, label)) + }) + .transpose()?) } } @@ -909,7 +910,7 @@ mod tests { txn.store_block( b.header(), &to_spent_txs(b.txs()), - Label::Final, + Label::Final(3), )?; Ok(()) }) @@ -956,7 +957,7 @@ mod tests { txn.store_block( b.header(), &to_spent_txs(b.txs()), - Label::Final, + Label::Final(3), ) .expect("block to be stored"); }); @@ -985,7 +986,7 @@ mod tests { txn.store_block( b.header(), &to_spent_txs(b.txs()), - Label::Final, + Label::Final(3), ) .unwrap(); @@ -1139,7 +1140,7 @@ mod tests { txn.store_block( b.header(), &to_spent_txs(b.txs()), - Label::Final, + Label::Final(3), )?; Ok(()) }) @@ -1173,7 +1174,7 @@ mod tests { txn.store_block( b.header(), &to_spent_txs(b.txs()), - Label::Attested, + Label::Attested(3), )?; Ok(()) }) @@ -1203,7 +1204,7 @@ mod tests { txn.store_block( b.header(), &to_spent_txs(b.txs()), - Label::Attested, + Label::Attested(3), )?; Ok(()) }) @@ -1216,7 +1217,7 @@ mod tests { .expect("should not return error") .expect("should find a block") .1 - .eq(&Label::Attested)); + .eq(&Label::Attested(3))); }); }); } @@ -1235,7 +1236,7 @@ mod tests { ut.store_block( b.header(), &to_spent_txs(b.txs()), - Label::Final, + Label::Final(3), )?; Ok(()) })