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§