logo
pub trait WalletSync {
    fn wallet_setup<D: BatchDatabase>(
        &self,
        database: &mut D,
        progress_update: Box<dyn Progress>
    ) -> Result<(), Error>; fn wallet_sync<D: BatchDatabase>(
        &self,
        database: &mut D,
        progress_update: Box<dyn Progress>
    ) -> Result<(), Error> { ... } }
Expand description

Trait for blockchains that can sync by updating the database directly.

Required Methods

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

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

Implementors