From 2df13c428f9740e563f0b2a960901b458db21e36 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 04:24:04 -1100 Subject: [PATCH 1/3] Workaround for -maxreorg --- src/komodo_defs.h | 3 ++- src/wallet/wallet.cpp | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index c0a3caffd..bd516be61 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -28,7 +28,8 @@ #define KOMODO_FIRSTFUNGIBLEID 100 #define KOMODO_SAPLING_ACTIVATION 1544832000 // Dec 15th, 2018 #define KOMODO_SAPLING_DEADLINE 1550188800 // Feb 15th, 2019 - +#define _COINBASE_MATURITY 100 + extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC; int32_t MAX_BLOCK_SIZE(int32_t height); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 024194695..969e0c81b 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1184,6 +1184,7 @@ bool DecrementNoteWitnesses(NoteDataMap& noteDataMap, int indexHeight, int64_t n return true; } + void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) { LOCK(cs_wallet); @@ -1193,10 +1194,17 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) if (!::DecrementNoteWitnesses(wtxItem.second.mapSaplingNoteData, pindex->GetHeight(), nWitnessCacheSize)) needsRescan = true; } - nWitnessCacheSize -= 1; - // TODO: If nWitnessCache is zero, we need to regenerate the caches (#1302) - assert(nWitnessCacheSize > 0); - + if ( WITNESS_CACHE_SIZE == _COINBASE_MATURITY+10 ) + { + nWitnessCacheSize -= 1; + // TODO: If nWitnessCache is zero, we need to regenerate the caches (#1302) + assert(nWitnessCacheSize > 0); + } + else + { + if ( nWitnessCacheSize > 0 ) + nWitnessCacheSize-- + } // For performance reasons, we write out the witness cache in // CWallet::SetBestChain() (which also ensures that overall consistency // of the wallet.dat is maintained). From 512d96862abc5ab95bd0afd1bd6fd695458f14f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 04:30:24 -1100 Subject: [PATCH 2/3] Help human instructions for -maxreorg --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index f5e5a6ab0..b29e80efc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4114,7 +4114,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo "- " + strprintf(_("Fork point: %s %s, height %d"), ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->GetHeight()) + "\n\n" + _("Please help, human!"); - LogPrintf("*** %s\n", msg); + LogPrintf("*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg,reorgLength+10); uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR); StartShutdown(); return false; From 4f48570935324e2c3a531bfb084810764e7d1fff Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Jan 2019 04:31:04 -1100 Subject: [PATCH 3/3] ; --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 969e0c81b..dd188d418 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1203,8 +1203,8 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) else { if ( nWitnessCacheSize > 0 ) - nWitnessCacheSize-- - } + nWitnessCacheSize--; + } // For performance reasons, we write out the witness cache in // CWallet::SetBestChain() (which also ensures that overall consistency // of the wallet.dat is maintained).