pub async fn sync<P, W>(
client: CompactTxStreamerClient<UnderlyingService>,
consensus_parameters: &P,
wallet: Arc<RwLock<W>>,
sync_mode: Arc<AtomicU8>,
config: SyncConfig,
) -> Result<SyncResult, SyncError<W::Error>>where
P: Parameters + Sync + Send + 'static,
W: SyncWallet + SyncBlocks + SyncTransactions + SyncNullifiers + SyncOutPoints + SyncShardTrees + Send,Expand description
Syncs a wallet to the latest state of the blockchain.
sync_mode is intended to be stored in a struct that owns the wallet(s) (i.e. lightclient) and has a non-atomic
counterpart crate::wallet::SyncMode. The sync engine will set the sync_mode to Running at the start of sync.
However, the consumer is required to set the sync_mode back to NotRunning when sync is succussful or returns an
error. This allows more flexibility and safety with sync task handles etc.
sync_mode may also be set to Paused externally to pause scanning so the wallet lock can be acquired multiple
times in quick sucession without the sync engine interrupting.
Set sync_mode back to Running to resume scanning.
Set sync_mode to Shutdown to stop the sync process.