diff --git a/src/avalanche.cpp b/src/avalanche.cpp --- a/src/avalanche.cpp +++ b/src/avalanche.cpp @@ -413,12 +413,9 @@ reverse_iterate(r)) { const CBlockIndex *pindex = p.first; - { - LOCK(cs_main); - if (!IsWorthPolling(pindex)) { - // Obviously do not poll if the block is not worth polling. - continue; - } + if (!IsWorthPolling(pindex)) { + // Obviously do not poll if the block is not worth polling. + continue; } // Check if we can run poll. @@ -519,7 +516,9 @@ * up over time. */ std::vector invs; + LOCK(cs_main); bool hasSent = connman->ForNode(nodeid, [this, &invs](CNode *pnode) { + AssertLockHeld(cs_main); invs = getInvsForNextPoll(); if (invs.empty()) { return false;