From b8ebbd7da55fcf230b64a41d433900a2633f0394 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 27 Jun 2021 12:52:45 -0700 Subject: [PATCH] Add -keepnotewitnesscache for advanced users --- src/init.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index ab4e1c0d8..5e7a644f4 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2073,9 +2073,15 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) CBlockIndex *pindexRescan = chainActive.Tip(); if (clearWitnessCaches || GetBoolArg("-rescan", false)) { - pwalletMain->ClearNoteWitnessCache(); - pindexRescan = chainActive.Genesis(); int rescanHeight = GetArg("-rescanheight", 0); + // Must be used with -rescanheight + if( GetBoolArg("-keepnotewitnesscache", false) && rescanHeight > 0 ) { + LogPrintf("%s: keeping NoteWitnessCache with rescan height=%d\n", __func__, rescanHeight); + } else { + pwalletMain->ClearNoteWitnessCache(); + } + + pindexRescan = chainActive.Genesis(); if (rescanHeight > 0) { if (rescanHeight > chainActive.Tip()->GetHeight()) { pindexRescan = chainActive.Tip();