From a9955c95f37f8a1d366d14f0be8109f2d40f86c4 Mon Sep 17 00:00:00 2001 From: CashewTTS <107768467+CashewTTS@users.noreply.github.com> Date: Sun, 21 Apr 2024 16:18:06 -0600 Subject: [PATCH] WalletSyncManager: immediately resync upon SyncFromHeight Previously, this resync would only occur upon receipt of the next new block. This caused confusion for some users, especially on slow or stalled blockchains. --- src/Features/Blockcore.Features.Wallet/WalletSyncManager.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Features/Blockcore.Features.Wallet/WalletSyncManager.cs b/src/Features/Blockcore.Features.Wallet/WalletSyncManager.cs index 89946812d..cf43a479b 100644 --- a/src/Features/Blockcore.Features.Wallet/WalletSyncManager.cs +++ b/src/Features/Blockcore.Features.Wallet/WalletSyncManager.cs @@ -322,6 +322,12 @@ public virtual void SyncFromHeight(int height) this.walletTip = chainedHeader ?? throw new WalletException("Invalid block height"); this.walletManager.WalletTipHash = chainedHeader.HashBlock; this.walletManager.WalletTipHeight = chainedHeader.Height; + + // Rather than waiting for a new block to be received, which could take a while, immediately + // trigger resync from after the newly-set wallet tip through the current consensus tip. + // Note that we are taking advantage of how OnProcessBlockAsync will iterate over any blocks + // in the consensus chain between the wallet tip and this block. + this.ProcessBlock(this.blockStore.GetBlock(this.chainIndexer.Tip.HashBlock)); } ///