perf(spv): persist checkpoint-anchoring state across sync sessions
_anchoredUpTo tracked which heights were already proven to hash-chain back to a checkpoint, but only in memory: every app restart re-walked and re-verified the whole header chain from the checkpoint even when the header bytes themselves were already cached on disk, dominating reconnect time on large wallets. Round-trip it through SyncCache like the other sync caches (RawTxHex/VerifiedAt/BlockHeaders).
This commit is contained in:
+4
-2
@@ -140,10 +140,11 @@ static async Task<int> Sync(string[] o)
|
||||
doc.Cache?.BlockHeaders,
|
||||
doc.Cache?.NextReceiveIndex ?? 0,
|
||||
doc.Cache?.NextChangeIndex ?? 0,
|
||||
net);
|
||||
net,
|
||||
doc.Cache?.AnchoredUpTo);
|
||||
var result = await sync.SyncOnceAsync();
|
||||
|
||||
var (rawHex, verifiedAt, blockHeaders) = sync.ExportCaches(net);
|
||||
var (rawHex, verifiedAt, blockHeaders, anchoredUpTo) = sync.ExportCaches(net);
|
||||
doc.Cache = new SyncCache
|
||||
{
|
||||
TipHeight = result.TipHeight,
|
||||
@@ -160,6 +161,7 @@ static async Task<int> Sync(string[] o)
|
||||
RawTxHex = rawHex,
|
||||
VerifiedAt = verifiedAt,
|
||||
BlockHeaders = blockHeaders,
|
||||
AnchoredUpTo = anchoredUpTo,
|
||||
};
|
||||
WalletStore.Save(doc, path, Opt(o, "--password"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user