Trait AddressCacheDatabase

Source
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§

Source

type Error: Debug + Send + Sync + 'static

Required Methods§

Source

fn save(&self, address: &CachedAddress)

Saves a new address to the database. If the address already exists, update should be used instead

Source

fn load(&self) -> Result<Vec<CachedAddress>, Self::Error>

Loads all addresses we have cached so far

Source

fn get_stats(&self) -> Result<Stats, Self::Error>

Loads the data associated with our watch-only wallet.

Source

fn save_stats(&self, stats: &Stats) -> Result<(), Self::Error>

Saves the data associated with our watch-only wallet.

Source

fn update(&self, address: &CachedAddress)

Updates an address, probably because a new transaction arrived

Source

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

Source

fn set_cache_height(&self, height: u32) -> Result<(), Self::Error>

Saves the height of the last block we filtered

Source

fn desc_save(&self, descriptor: &str) -> Result<(), Self::Error>

Saves the descriptor of associated cache

Source

fn descs_get(&self) -> Result<Vec<String>, Self::Error>

Get associated descriptors

Source

fn get_transaction(&self, txid: &Txid) -> Result<CachedTransaction, Self::Error>

Get a transaction from the database

Source

fn save_transaction(&self, tx: &CachedTransaction) -> Result<(), Self::Error>

Saves a transaction to the database

Source

fn list_transactions(&self) -> Result<Vec<Txid>, Self::Error>

Returns all transaction we have cached so far

Implementors§