Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed note_hash to note_id #336

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/block-producer/src/test_utils/proven_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ impl MockProvenTxBuilder {
pub fn private_notes_created_range(self, range: Range<u64>) -> Self {
let notes = range
.map(|note_index| {
let note_hash = Hasher::hash(&note_index.to_be_bytes());
let note_id = Hasher::hash(&note_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();

Expand Down
2 changes: 1 addition & 1 deletion crates/store/src/db/migrations/001-init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions crates/store/src/db/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ pub fn select_notes(conn: &mut Connection) -> Result<Vec<NoteRecord>> {
block_num,
batch_index,
note_index,
note_hash,
note_id,
note_type,
sender,
tag,
Expand Down Expand Up @@ -380,7 +380,7 @@ pub fn insert_notes(transaction: &Transaction, notes: &[NoteRecord]) -> Result<u
block_num,
batch_index,
note_index,
note_hash,
note_id,
note_type,
sender,
tag,
Expand Down Expand Up @@ -440,7 +440,7 @@ pub fn select_notes_since_block_by_tag_and_sender(
block_num,
batch_index,
note_index,
note_hash,
note_id,
note_type,
sender,
tag,
Expand Down Expand Up @@ -503,7 +503,7 @@ pub fn select_notes_since_block_by_tag_and_sender(
/// # Returns
///
/// - Empty vector if no matching `note`.
/// - Otherwise, notes which `note_hash` matches the `NoteId` as bytes.
/// - Otherwise, notes which `note_id` matches the `NoteId` as bytes.
pub fn select_notes_by_id(conn: &mut Connection, note_ids: &[NoteId]) -> Result<Vec<NoteRecord>> {
let note_ids: Vec<Value> = note_ids.iter().map(|id| id.to_bytes().into()).collect();

Expand All @@ -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,
Expand All @@ -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)])?;
Expand Down