diff --git a/src/avalanche/processor.cpp b/src/avalanche/processor.cpp --- a/src/avalanche/processor.cpp +++ b/src/avalanche/processor.cpp @@ -152,14 +152,6 @@ // Make sure we get notified of chain state changes. chainNotificationsHandler = chain.handleNotifications(std::make_shared(this)); - - scheduler.scheduleEvery( - [this]() -> bool { - WITH_LOCK(cs_peerManager, - peerManager->cleanupDanglingProofs(getLocalProof())); - return true; - }, - 5min); } Processor::~Processor() { diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include // For AVALANCHE_LEGACY_PROOF_DEFAULT #include @@ -2577,6 +2578,16 @@ return false; } + avalanche::Processor *processor = g_avalanche.get(); + node.scheduler->scheduleEvery( + [processor]() -> bool { + processor->withPeerManager([&](avalanche::PeerManager &pm) { + pm.cleanupDanglingProofs(processor->getLocalProof()); + }); + return true; + }, + 5min); + if (isAvalancheEnabled(args) && g_avalanche->isAvalancheServiceAvailable()) { nLocalServices = ServiceFlags(nLocalServices | NODE_AVALANCHE);