fix ngone after KCV API change

master
Niko PLP 3 weeks ago
parent d80f3d5d1a
commit f4c9db5d26
  1. 15
      ngone/src/store/dynpeer.rs
  2. 28
      ngone/src/store/wallet_record.rs

@ -61,6 +61,7 @@ impl<'a> DynPeer<'a> {
&to_vec(&id)?, &to_vec(&id)?,
Some(Self::ADDRS), Some(Self::ADDRS),
&to_vec(&addrs)?, &to_vec(&addrs)?,
&None,
)?; )?;
Ok(()) Ok(())
})?; })?;
@ -72,6 +73,7 @@ impl<'a> DynPeer<'a> {
Self::PREFIX, Self::PREFIX,
&to_vec(&self.id).unwrap(), &to_vec(&self.id).unwrap(),
Some(Self::SUFFIX_FOR_EXIST_CHECK), Some(Self::SUFFIX_FOR_EXIST_CHECK),
&None,
) )
.is_ok() .is_ok()
} }
@ -86,16 +88,21 @@ impl<'a> DynPeer<'a> {
Self::PREFIX, Self::PREFIX,
&to_vec(&self.id)?, &to_vec(&self.id)?,
Some(Self::ADDRS), Some(Self::ADDRS),
to_vec(addrs)?, &to_vec(addrs)?,
&None,
) )
} }
pub fn remove_addresses(&self) -> Result<(), StorageError> { pub fn remove_addresses(&self) -> Result<(), StorageError> {
self.store self.store
.del(Self::PREFIX, &to_vec(&self.id)?, Some(Self::ADDRS)) .del(Self::PREFIX, &to_vec(&self.id)?, Some(Self::ADDRS), &None)
} }
pub fn del(&self) -> Result<(), StorageError> { pub fn del(&self) -> Result<(), StorageError> {
self.store self.store.del_all(
.del_all(Self::PREFIX, &to_vec(&self.id)?, &Self::ALL_PROPERTIES) Self::PREFIX,
&to_vec(&self.id)?,
&Self::ALL_PROPERTIES,
&None,
)
} }
} }

@ -64,6 +64,7 @@ impl<'a> WalletRecord<'a> {
&to_vec(&id)?, &to_vec(&id)?,
Some(Self::BOOTSTRAP), Some(Self::BOOTSTRAP),
&to_vec(bootstrap)?, &to_vec(bootstrap)?,
&None,
)?; )?;
Ok(()) Ok(())
})?; })?;
@ -75,6 +76,7 @@ impl<'a> WalletRecord<'a> {
Self::PREFIX, Self::PREFIX,
&to_vec(&self.id).unwrap(), &to_vec(&self.id).unwrap(),
Some(Self::SUFFIX_FOR_EXIST_CHECK), Some(Self::SUFFIX_FOR_EXIST_CHECK),
&None,
) )
.is_ok() .is_ok()
} }
@ -89,7 +91,8 @@ impl<'a> WalletRecord<'a> {
Self::PREFIX, Self::PREFIX,
&to_vec(&self.id)?, &to_vec(&self.id)?,
Some(Self::WALLET), Some(Self::WALLET),
to_vec(wallet)?, &to_vec(wallet)?,
&None,
) )
} }
@ -101,14 +104,15 @@ impl<'a> WalletRecord<'a> {
Self::PREFIX, Self::PREFIX,
&to_vec(&self.id)?, &to_vec(&self.id)?,
Some(Self::BOOTSTRAP), Some(Self::BOOTSTRAP),
to_vec(boot)?, &to_vec(boot)?,
&None,
) )
} }
pub fn wallet(&self) -> Result<Wallet, StorageError> { pub fn wallet(&self) -> Result<Wallet, StorageError> {
match self match self
.store .store
.get(Self::PREFIX, &to_vec(&self.id)?, Some(Self::WALLET)) .get(Self::PREFIX, &to_vec(&self.id)?, Some(Self::WALLET), &None)
{ {
Ok(w) => Ok(from_slice::<Wallet>(&w)?), Ok(w) => Ok(from_slice::<Wallet>(&w)?),
Err(e) => Err(e), Err(e) => Err(e),
@ -116,17 +120,23 @@ impl<'a> WalletRecord<'a> {
} }
pub fn bootstrap(&self) -> Result<Bootstrap, StorageError> { pub fn bootstrap(&self) -> Result<Bootstrap, StorageError> {
match self match self.store.get(
.store Self::PREFIX,
.get(Self::PREFIX, &to_vec(&self.id)?, Some(Self::BOOTSTRAP)) &to_vec(&self.id)?,
{ Some(Self::BOOTSTRAP),
&None,
) {
Ok(meta) => Ok(from_slice::<Bootstrap>(&meta)?), Ok(meta) => Ok(from_slice::<Bootstrap>(&meta)?),
Err(e) => Err(e), Err(e) => Err(e),
} }
} }
pub fn del(&self) -> Result<(), StorageError> { pub fn del(&self) -> Result<(), StorageError> {
self.store self.store.del_all(
.del_all(Self::PREFIX, &to_vec(&self.id)?, &Self::ALL_PROPERTIES) Self::PREFIX,
&to_vec(&self.id)?,
&Self::ALL_PROPERTIES,
&None,
)
} }
} }

Loading…
Cancel
Save