diff --git a/nostrdb b/nostrdb index 423598b..7c047ab 160000 --- a/nostrdb +++ b/nostrdb @@ -1 +1 @@ -Subproject commit 423598b0f747920369a8625d9aca5298b8e6aa59 +Subproject commit 7c047ab79051218601930470d3d3d8d47842fc8b diff --git a/src/ndb.rs b/src/ndb.rs index 9d76aba..6f43502 100644 --- a/src/ndb.rs +++ b/src/ndb.rs @@ -297,7 +297,7 @@ impl Ndb { )) } - pub fn get_notekey_by_id(&self, txn: &Transaction, id: &[u8; 32]) -> Result { + pub fn get_notekey_by_id(&self, txn: &Transaction, id: &[u8; 32]) -> Result { let res = unsafe { bindings::ndb_get_notekey_by_id( txn.as_mut_ptr(), @@ -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 { + 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>(