From d7338d5b8726ffbe834c86e9e41f2ba400a2249e Mon Sep 17 00:00:00 2001 From: Calin Culianu Date: Sun, 15 Dec 2019 09:14:56 +0200 Subject: [PATCH] Moved a lock up to top in addBlock --- Storage.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Storage.cpp b/Storage.cpp index 73195f2..837e9b8 100644 --- a/Storage.cpp +++ b/Storage.cpp @@ -863,7 +863,9 @@ QString Storage::addBlock(PreProcessedBlockPtr ppb, bool saveUndo, unsigned nRes QString errRet; - std::scoped_lock guard(p->headerVerifierLock); // take all locks now.. todo: add more locks here + // take all locks now.. since this is a Big Deal. TODO: add more locks here? + std::scoped_lock guard(p->headerVerifierLock, p->blkInfoLock); + const auto verifUndo = p->headerVerifier; // keep a copy for undo purposes in case this fails try { @@ -1025,8 +1027,6 @@ QString Storage::addBlock(PreProcessedBlockPtr ppb, bool saveUndo, unsigned nRes { // update BlkInfo - ExclusiveLockGuard g(p->blkInfoLock); - if (nReserve) { if (const auto size = p->blkInfos.size(); size + 1 > p->blkInfos.capacity()) p->blkInfos.reserve(size + nReserve); // reserve space for new blkinfos in 1 go to save on copying