diff --git a/src/init.cpp b/src/init.cpp index 16fe7d0bbcfb7..fbbcd2a0d587d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2366,7 +2366,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA node.scheduler->scheduleEvery(std::bind(&CNetFulfilledRequestManager::DoMaintenance, std::ref(netfulfilledman)), 60 * 1000); node.scheduler->scheduleEvery(std::bind(&CMasternodeSync::DoMaintenance, std::ref(masternodeSync), std::ref(*node.connman)), 1 * 1000); - node.scheduler->scheduleEvery(std::bind(&CMasternodeUtils::DoMaintenance, std::ref(*node.connman)), 1 * 1000); + node.scheduler->scheduleEvery(std::bind(&CMasternodeUtils::DoMaintenance, std::ref(*node.connman)), 60 * 1000); node.scheduler->scheduleEvery(std::bind(&CDeterministicMNManager::DoMaintenance, std::ref(*deterministicMNManager)), 10 * 1000); if (!fDisableGovernance) { diff --git a/src/masternode/utils.cpp b/src/masternode/utils.cpp index 55f0b94c3570f..e7611ff78ae09 100644 --- a/src/masternode/utils.cpp +++ b/src/masternode/utils.cpp @@ -15,8 +15,11 @@ #include -void CMasternodeUtils::ProcessMasternodeConnections(CConnman& connman) +void CMasternodeUtils::DoMaintenance(CConnman& connman) { + if(!masternodeSync.IsBlockchainSynced() || ShutdownRequested()) + return; + std::vector vecDmns; // will be empty when no wallet #ifdef ENABLE_WALLET for (const auto& pair : coinJoinClientManagers) { @@ -77,18 +80,3 @@ void CMasternodeUtils::ProcessMasternodeConnections(CConnman& connman) pnode->fDisconnect = true; }); } - -void CMasternodeUtils::DoMaintenance(CConnman& connman) -{ - if(!masternodeSync.IsBlockchainSynced() || ShutdownRequested()) - return; - - static unsigned int nTick = 0; - - nTick++; - - if(nTick % 60 == 0) { - ProcessMasternodeConnections(connman); - } -} - diff --git a/src/masternode/utils.h b/src/masternode/utils.h index 7dcfb69647a93..69d1ca9f0c1d6 100644 --- a/src/masternode/utils.h +++ b/src/masternode/utils.h @@ -10,7 +10,6 @@ class CConnman; class CMasternodeUtils { public: - static void ProcessMasternodeConnections(CConnman& connman); static void DoMaintenance(CConnman &connman); }; diff --git a/test/functional/feature_llmq_connections.py b/test/functional/feature_llmq_connections.py index 51852b1e11d6e..cfc101965b7aa 100755 --- a/test/functional/feature_llmq_connections.py +++ b/test/functional/feature_llmq_connections.py @@ -69,6 +69,22 @@ def run_test(self): self.check_reconnects(4) + self.log.info("check that old masternode conections are dropped") + removed = False + for mn in self.mninfo: + if len(mn.node.quorum("memberof", mn.proTxHash)) > 0: + try: + with mn.node.assert_debug_log(['removing masternodes quorum connections']): + with mn.node.assert_debug_log(['keeping mn quorum connections']): + self.mine_quorum() + mn.node.mockscheduler(60) # we check for old connections via the scheduler every 60 seconds + removed = True + except: + pass # it's ok to not remove connections sometimes + if removed: + break + assert removed # no way we removed none + def check_reconnects(self, expected_connection_count): self.log.info("disable and re-enable networking on all masternodes") for mn in self.mninfo: