Skip to content

Commit

Permalink
add get_profilekey_by_pubkey
Browse files Browse the repository at this point in the history
This is for quickly checking for the existence of a profile and saving
the key for a faster lookup later.

Changelog-Added: Add get_profilekey_by_pubkey
Signed-off-by: William Casarin <[email protected]>
  • Loading branch information
jb55 committed Dec 16, 2024
1 parent 2da7d56 commit d7ad4a4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nostrdb
Submodule nostrdb updated 1 files
+1 −0 src/nostrdb.c
23 changes: 21 additions & 2 deletions src/ndb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl Ndb {
))
}

pub fn get_notekey_by_id(&self, txn: &Transaction, id: &[u8; 32]) -> Result<u64> {
pub fn get_notekey_by_id(&self, txn: &Transaction, id: &[u8; 32]) -> Result<NoteKey> {
let res = unsafe {
bindings::ndb_get_notekey_by_id(
txn.as_mut_ptr(),
Expand All @@ -309,7 +309,26 @@ impl Ndb {
return Err(Error::NotFound);
}

Ok(res)
Ok(NoteKey::new(res))
}

pub fn get_profilekey_by_pubkey(
&self,
txn: &Transaction,
pubkey: &[u8; 32],
) -> Result<ProfileKey> {
let res = unsafe {
bindings::ndb_get_profilekey_by_pubkey(
txn.as_mut_ptr(),
pubkey.as_ptr() as *const ::std::os::raw::c_uchar,
)
};

if res == 0 {
return Err(Error::NotFound);
}

Ok(ProfileKey::new(res))
}

pub fn get_blocks_by_key<'a>(
Expand Down

0 comments on commit d7ad4a4

Please sign in to comment.