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