pub async fn sync<C, P, W>(
client: C,
consensus_parameters: &P,
wallet: Arc<RwLock<W>>,
sync_mode: Arc<AtomicU8>,
progress: Sender<Option<SyncStatus>>,
config: SyncConfig,
) -> Result<SyncResult, SyncError<W::Error>>where
C: Clone + Indexer + TransparentIndexer + Sync + Send + 'static,
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.
With shutdown_on_completion set, a scan that reaches the chain tip moves a Running engine to Shutdown and
leaves a Paused engine paused, which then shuts down once it is resumed and completes again.
Wallet keys must not change while sync is running. Sync must be stoppped and run again after the key material has
been updated.