Skip to content

Commit

Permalink
Block ActivateBestChain to empty validationinterface queue
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt authored and furszy committed Feb 21, 2021
1 parent 0c68e2f commit cc91d44
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
#include "zpiv/zerocoin.h"
#include "zpiv/zpivmodule.h"

#include <future>

#include <boost/algorithm/string/replace.hpp>
#include <boost/thread.hpp>
#include <atomic>
Expand Down Expand Up @@ -2258,6 +2260,17 @@ bool ActivateBestChain(CValidationState& state, std::shared_ptr<const CBlock> pb
do {
boost::this_thread::interruption_point();

if (GetMainSignals().CallbacksPending() > 10) {
// Block until the validation queue drains. This should largely
// never happen in normal operation, however may happen during
// reindex, causing memory blowup if we run too far ahead.
std::promise<void> promise;
CallFunctionInValidationInterfaceQueue([&promise] {
promise.set_value();
});
promise.get_future().wait();
}

const CBlockIndex *pindexFork;
bool fInitialDownload;
while (true) {
Expand Down

0 comments on commit cc91d44

Please sign in to comment.