From 3a758883bb2cace92e29734e72422349f5589664 Mon Sep 17 00:00:00 2001 From: polydez <155382956+polydez@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:00:05 +0500 Subject: [PATCH] refactor: rename `note_hash` to `note_id` --- crates/block-producer/src/test_utils/proven_tx.rs | 4 ++-- crates/store/src/db/migrations/001-init.sql | 2 +- crates/store/src/db/sql.rs | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/block-producer/src/test_utils/proven_tx.rs b/crates/block-producer/src/test_utils/proven_tx.rs index d934ddaad..34631c503 100644 --- a/crates/block-producer/src/test_utils/proven_tx.rs +++ b/crates/block-producer/src/test_utils/proven_tx.rs @@ -68,11 +68,11 @@ impl MockProvenTxBuilder { pub fn private_notes_created_range(self, range: Range) -> Self { let notes = range .map(|note_index| { - let note_hash = Hasher::hash(¬e_index.to_be_bytes()); + let note_id = Hasher::hash(¬e_index.to_be_bytes()); let note_metadata = NoteMetadata::new(self.account_id, NoteType::OffChain, 0.into(), ONE).unwrap(); - OutputNote::Private(NoteEnvelope::new(note_hash.into(), note_metadata).unwrap()) + OutputNote::Private(NoteEnvelope::new(note_id.into(), note_metadata).unwrap()) }) .collect(); diff --git a/crates/store/src/db/migrations/001-init.sql b/crates/store/src/db/migrations/001-init.sql index 95777f88c..4d808bfb6 100644 --- a/crates/store/src/db/migrations/001-init.sql +++ b/crates/store/src/db/migrations/001-init.sql @@ -26,7 +26,7 @@ CREATE TABLE block_num INTEGER NOT NULL, batch_index INTEGER NOT NULL, -- Index of batch in block, starting from 0 note_index INTEGER NOT NULL, -- Index of note in batch, starting from 0 - note_hash BLOB NOT NULL, + note_id BLOB NOT NULL, note_type INTEGER NOT NULL, -- 1-Public (0b01), 2-OffChain (0b10), 3-Encrypted (0b11) sender INTEGER NOT NULL, tag INTEGER NOT NULL, diff --git a/crates/store/src/db/sql.rs b/crates/store/src/db/sql.rs index 273ed0222..823e64a7c 100644 --- a/crates/store/src/db/sql.rs +++ b/crates/store/src/db/sql.rs @@ -322,7 +322,7 @@ pub fn select_notes(conn: &mut Connection) -> Result> { block_num, batch_index, note_index, - note_hash, + note_id, note_type, sender, tag, @@ -380,7 +380,7 @@ pub fn insert_notes(transaction: &Transaction, notes: &[NoteRecord]) -> Result Result> { let note_ids: Vec = note_ids.iter().map(|id| id.to_bytes().into()).collect(); @@ -513,7 +513,7 @@ pub fn select_notes_by_id(conn: &mut Connection, note_ids: &[NoteId]) -> Result< block_num, batch_index, note_index, - note_hash, + note_id, note_type, sender, tag, @@ -522,7 +522,7 @@ pub fn select_notes_by_id(conn: &mut Connection, note_ids: &[NoteId]) -> Result< FROM notes WHERE - note_hash IN rarray(?1) + note_id IN rarray(?1) ", )?; let mut rows = stmt.query(params![Rc::new(note_ids)])?;