Skip to content

Commit

Permalink
ndb: remove mutability on transaction reference
Browse files Browse the repository at this point in the history
It is unnecessary
  • Loading branch information
jb55 committed Dec 19, 2023
1 parent c02f10c commit 21d0002
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ndb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ impl Ndb {

pub fn get_profile_by_pubkey<'a>(
&self,
transaction: &'a mut Transaction,
transaction: &'a Transaction,
id: &[u8; 32],
) -> Result<ProfileRecord<'a>> {
let mut len: usize = 0;
let mut primkey: u64 = 0;

let profile_record_ptr = unsafe {
bindings::ndb_get_profile_by_pubkey(
transaction.as_mut_ptr(),
transaction.as_ptr() as *mut bindings::ndb_txn,
id.as_ptr(),
&mut len,
&mut primkey,
Expand All @@ -112,15 +112,15 @@ impl Ndb {
/// Get a note from the database. Takes a [Transaction] and a 32-byte [Note] Id
pub fn get_note_by_id<'a>(
&self,
transaction: &'a mut Transaction,
transaction: &'a Transaction,
id: &[u8; 32],
) -> Result<Note<'a>> {
let mut len: usize = 0;
let mut primkey: u64 = 0;

let note_ptr = unsafe {
bindings::ndb_get_note_by_id(
transaction.as_mut_ptr(),
transaction.as_ptr() as *mut bindings::ndb_txn,
id.as_ptr(),
&mut len,
&mut primkey,
Expand Down
8 changes: 8 additions & 0 deletions src/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ impl<'a> Note<'a> {
}
}

/// Get the note pubkey
pub fn pubkey(&self) -> &'a [u8; 32] {
unsafe {
let ptr = bindings::ndb_note_pubkey(self.as_ptr());
&*(ptr as *const [u8; 32])
}
}

pub fn kind(&self) -> u32 {
unsafe { bindings::ndb_note_kind(self.as_ptr()) }
}
Expand Down

0 comments on commit 21d0002

Please sign in to comment.