mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-20 03:57:03 +00:00
storage: read_or_create_person_relay()
This commit is contained in:
parent
3cb1927e0e
commit
d8f59b4255
@ -1928,6 +1928,24 @@ impl Storage {
|
|||||||
self.modify_person_relay2(pubkey, url, modify, rw_txn)
|
self.modify_person_relay2(pubkey, url, modify, rw_txn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Read a person record, create if missing
|
||||||
|
#[inline]
|
||||||
|
pub fn read_or_create_person_relay<'a>(
|
||||||
|
&'a self,
|
||||||
|
pubkey: PublicKey,
|
||||||
|
url: &RelayUrl,
|
||||||
|
rw_txn: Option<&mut RwTxn<'a>>,
|
||||||
|
) -> Result<PersonRelay, Error> {
|
||||||
|
match self.read_person_relay(pubkey, url)? {
|
||||||
|
Some(pr) => Ok(pr),
|
||||||
|
None => {
|
||||||
|
let person_relay = PersonRelay::new(pubkey.to_owned(), url.to_owned());
|
||||||
|
self.write_person_relay(&person_relay, rw_txn)?;
|
||||||
|
Ok(person_relay)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// get PersonRelay records for a person
|
/// get PersonRelay records for a person
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_person_relays(&self, pubkey: PublicKey) -> Result<Vec<PersonRelay>, Error> {
|
pub fn get_person_relays(&self, pubkey: PublicKey) -> Result<Vec<PersonRelay>, Error> {
|
||||||
|
Loading…
Reference in New Issue
Block a user