Trait bdk_debug::blockchain::WalletSync
source · pub trait WalletSync {
// Required method
fn wallet_setup<D: BatchDatabase>(
&self,
database: &RefCell<D>,
progress_update: Box<dyn Progress>
) -> Result<(), Error>;
// Provided method
fn wallet_sync<D: BatchDatabase>(
&self,
database: &RefCell<D>,
progress_update: Box<dyn Progress>
) -> Result<(), Error> { ... }
}Expand description
Trait for blockchains that can sync by updating the database directly.
Required Methods§
sourcefn wallet_setup<D: BatchDatabase>(
&self,
database: &RefCell<D>,
progress_update: Box<dyn Progress>
) -> Result<(), Error>
fn wallet_setup<D: BatchDatabase>( &self, database: &RefCell<D>, progress_update: Box<dyn Progress> ) -> Result<(), Error>
Setup the backend and populate the internal database for the first time
This method is the equivalent of Self::wallet_sync, but it’s guaranteed to only be
called once, at the first Wallet::sync.
The rationale behind the distinction between sync and setup is that some custom backends
might need to perform specific actions only the first time they are synced.
For types that do not have that distinction, only this method can be implemented, since
WalletSync::wallet_sync defaults to calling this internally if not overridden.
Populate the internal database with transactions and UTXOs
Provided Methods§
sourcefn wallet_sync<D: BatchDatabase>(
&self,
database: &RefCell<D>,
progress_update: Box<dyn Progress>
) -> Result<(), Error>
fn wallet_sync<D: BatchDatabase>( &self, database: &RefCell<D>, progress_update: Box<dyn Progress> ) -> Result<(), Error>
If not overridden, it defaults to calling Self::wallet_setup internally.
This method should implement the logic required to iterate over the list of the wallet’s
script_pubkeys using Database::iter_script_pubkeys and look for relevant transactions
in the blockchain to populate the database with BatchOperations::set_tx and
BatchOperations::set_utxo.
This method should also take care of removing UTXOs that are seen as spent in the
blockchain, using BatchOperations::del_utxo.
The progress_update object can be used to give the caller updates about the progress by using
Progress::update.
Implementations on Foreign Types§
source§impl<T: WalletSync> WalletSync for Arc<T>
impl<T: WalletSync> WalletSync for Arc<T>
fn wallet_setup<D: BatchDatabase>( &self, database: &RefCell<D>, progress_update: Box<dyn Progress> ) -> Result<(), Error>
fn wallet_sync<D: BatchDatabase>( &self, database: &RefCell<D>, progress_update: Box<dyn Progress> ) -> Result<(), Error>
Implementors§
impl WalletSync for AnyBlockchain
impl WalletSync for CompactFiltersBlockchain
compact_filters only.impl WalletSync for ElectrumBlockchain
electrum only.impl WalletSync for EsploraBlockchain
esplora only.impl WalletSync for RpcBlockchain
rpc only.