pub trait AddressCacheDatabase {
type Error: Debug + Send + Sync + 'static;
// Required methods
fn save(&self, address: &CachedAddress);
fn load(&self) -> Result<Vec<CachedAddress>, Self::Error>;
fn get_stats(&self) -> Result<Stats, Self::Error>;
fn save_stats(&self, stats: &Stats) -> Result<(), Self::Error>;
fn update(&self, address: &CachedAddress);
fn get_cache_height(&self) -> Result<u32, Self::Error>;
fn set_cache_height(&self, height: u32) -> Result<(), Self::Error>;
fn desc_save(&self, descriptor: &str) -> Result<(), Self::Error>;
fn descs_get(&self) -> Result<Vec<String>, Self::Error>;
fn get_transaction(
&self,
txid: &Txid,
) -> Result<CachedTransaction, Self::Error>;
fn save_transaction(
&self,
tx: &CachedTransaction,
) -> Result<(), Self::Error>;
fn list_transactions(&self) -> Result<Vec<Txid>, Self::Error>;
}Expand description
Public trait defining a common interface for databases to be used with our cache
Required Associated Types§
Required Methods§
Sourcefn save(&self, address: &CachedAddress)
fn save(&self, address: &CachedAddress)
Saves a new address to the database. If the address already exists, update should
be used instead
Sourcefn load(&self) -> Result<Vec<CachedAddress>, Self::Error>
fn load(&self) -> Result<Vec<CachedAddress>, Self::Error>
Loads all addresses we have cached so far
Sourcefn get_stats(&self) -> Result<Stats, Self::Error>
fn get_stats(&self) -> Result<Stats, Self::Error>
Loads the data associated with our watch-only wallet.
Sourcefn save_stats(&self, stats: &Stats) -> Result<(), Self::Error>
fn save_stats(&self, stats: &Stats) -> Result<(), Self::Error>
Saves the data associated with our watch-only wallet.
Sourcefn update(&self, address: &CachedAddress)
fn update(&self, address: &CachedAddress)
Updates an address, probably because a new transaction arrived
Sourcefn get_cache_height(&self) -> Result<u32, Self::Error>
fn get_cache_height(&self) -> Result<u32, Self::Error>
TODO: Maybe turn this into another db Returns the height of the last block we filtered
Sourcefn set_cache_height(&self, height: u32) -> Result<(), Self::Error>
fn set_cache_height(&self, height: u32) -> Result<(), Self::Error>
Saves the height of the last block we filtered
Sourcefn desc_save(&self, descriptor: &str) -> Result<(), Self::Error>
fn desc_save(&self, descriptor: &str) -> Result<(), Self::Error>
Saves the descriptor of associated cache
Sourcefn get_transaction(&self, txid: &Txid) -> Result<CachedTransaction, Self::Error>
fn get_transaction(&self, txid: &Txid) -> Result<CachedTransaction, Self::Error>
Get a transaction from the database
Sourcefn save_transaction(&self, tx: &CachedTransaction) -> Result<(), Self::Error>
fn save_transaction(&self, tx: &CachedTransaction) -> Result<(), Self::Error>
Saves a transaction to the database
Sourcefn list_transactions(&self) -> Result<Vec<Txid>, Self::Error>
fn list_transactions(&self) -> Result<Vec<Txid>, Self::Error>
Returns all transaction we have cached so far
Implementors§
Source§impl AddressCacheDatabase for KvDatabase
impl AddressCacheDatabase for KvDatabase
type Error = KvDatabaseError
Source§impl AddressCacheDatabase for MemoryDatabase
Available on crate feature memory-database only.
impl AddressCacheDatabase for MemoryDatabase
Available on crate feature
memory-database only.