From b480d9a8297a28db4744200562c904c75f0595e5 Mon Sep 17 00:00:00 2001 From: Neotamandua <107320179+Neotamandua@users.noreply.github.com> Date: Fri, 20 Dec 2024 14:07:02 +0200 Subject: [PATCH] node: adjust hash to id function calls --- node/src/database/rocksdb.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/node/src/database/rocksdb.rs b/node/src/database/rocksdb.rs index 10d3ffdc8..f43190a16 100644 --- a/node/src/database/rocksdb.rs +++ b/node/src/database/rocksdb.rs @@ -318,7 +318,7 @@ impl<'db, DB: DBAccess> Ledger for DBTransaction<'db, DB> { LightBlock { header: header.clone(), transactions_ids: txs.iter().map(|t| t.inner.id()).collect(), - faults_ids: faults.iter().map(|f| f.hash()).collect(), + faults_ids: faults.iter().map(|f| f.id()).collect(), } .write(&mut buf)?; @@ -349,7 +349,7 @@ impl<'db, DB: DBAccess> Ledger for DBTransaction<'db, DB> { for f in faults { let mut d = vec![]; f.write(&mut d)?; - self.put_cf(cf, f.hash(), d)?; + self.put_cf(cf, f.id(), d)?; } } self.store_block_label(header.height, &header.hash, label)?; @@ -410,7 +410,7 @@ impl<'db, DB: DBAccess> Ledger for DBTransaction<'db, DB> { self.inner.delete_cf(self.ledger_txs_cf, tx.id())?; } for f in b.faults() { - self.inner.delete_cf(self.ledger_faults_cf, f.hash())?; + self.inner.delete_cf(self.ledger_faults_cf, f.id())?; } self.inner.delete_cf(self.ledger_cf, b.header().hash)?; @@ -1206,7 +1206,7 @@ impl node_data::Serializable for LightBlock { let len = self.faults_ids.len() as u32; w.write_all(&len.to_le_bytes())?; - // Write faults hashes + // Write faults id for f_id in &self.faults_ids { w.write_all(f_id)?; } @@ -1236,7 +1236,7 @@ impl node_data::Serializable for LightBlock { // Read faults count let len = Self::read_u32_le(r)?; - // Read faults hashes + // Read faults ids let mut faults_ids = vec![]; for _ in 0..len { let mut f_id = [0u8; 32]; @@ -1299,10 +1299,7 @@ mod tests { // Assert all faults are fully fetched from ledger as // well. for pos in 0..b.faults().len() { - assert_eq!( - db_blk.faults()[pos].hash(), - b.faults()[pos].hash() - ); + assert_eq!(db_blk.faults()[pos].id(), b.faults()[pos].id()); } });