@@ -84,13 +84,9 @@ void QuorumParticipant::UpdatedBlockTip(const CBlockIndex* pindexNew, CConnman&
8484 StartCleanupOldQuorumDataThread (pindexNew);
8585}
8686
87- void QuorumParticipant::CheckQuorumConnections (CConnman& connman, const Consensus::LLMQParams& llmqParams,
88- gsl::not_null<const CBlockIndex*> pindexNew) const
87+ Uint256HashSet QuorumParticipant::GetQuorumsToDelete (CConnman& connman, const Consensus::LLMQParams& llmqParams,
88+ gsl::not_null<const CBlockIndex*> pindexNew) const
8989{
90- if (m_mn_activeman == nullptr && !m_quorums_watch) return ;
91-
92- auto lastQuorums = m_qman.ScanQuorums (llmqParams.type , pindexNew, (size_t )llmqParams.keepOldConnections );
93-
9490 auto connmanQuorumsToDelete = connman.GetMasternodeQuorums (llmqParams.type );
9591
9692 // don't remove connections for the currently in-progress DKG round
@@ -114,6 +110,17 @@ void QuorumParticipant::CheckQuorumConnections(CConnman& connman, const Consensu
114110 LogPrint (BCLog::LLMQ, " QuorumParticipant::%s -- llmqType[%d] h[%d] keeping mn quorum connections for quorum: [%d:%s]\n " , __func__, ToUnderlying (llmqParams.type ), pindexNew->nHeight , curDkgHeight, curDkgBlock.ToString ());
115111 }
116112
113+ return connmanQuorumsToDelete;
114+ }
115+
116+ void QuorumParticipant::CheckQuorumConnections (CConnman& connman, const Consensus::LLMQParams& llmqParams,
117+ gsl::not_null<const CBlockIndex*> pindexNew) const
118+ {
119+ if (m_mn_activeman == nullptr && !m_quorums_watch) return ;
120+
121+ auto lastQuorums = m_qman.ScanQuorums (llmqParams.type , pindexNew, (size_t )llmqParams.keepOldConnections );
122+ auto deletableQuorums = GetQuorumsToDelete (connman, llmqParams, pindexNew);
123+
117124 const uint256 myProTxHash = m_mn_activeman != nullptr ? m_mn_activeman->GetProTxHash () : uint256 ();
118125
119126 bool isISType = llmqParams.type == Params ().GetConsensus ().llmqTypeDIP0024InstantSend ;
@@ -126,7 +133,7 @@ void QuorumParticipant::CheckQuorumConnections(CConnman& connman, const Consensu
126133 for (const auto & quorum : lastQuorums) {
127134 if (utils::EnsureQuorumConnections (llmqParams, connman, m_sporkman, {m_dmnman, m_qsnapman, m_chainman, quorum->m_quorum_base_block_index },
128135 m_dmnman.GetListAtChainTip (), myProTxHash, /* is_masternode=*/ m_mn_activeman != nullptr , m_quorums_watch)) {
129- if (connmanQuorumsToDelete .erase (quorum->qc ->quorumHash ) > 0 ) {
136+ if (deletableQuorums .erase (quorum->qc ->quorumHash ) > 0 ) {
130137 LogPrint (BCLog::LLMQ, " QuorumParticipant::%s -- llmqType[%d] h[%d] keeping mn quorum connections for quorum: [%d:%s]\n " , __func__, ToUnderlying (llmqParams.type ), pindexNew->nHeight , quorum->m_quorum_base_block_index ->nHeight , quorum->m_quorum_base_block_index ->GetBlockHash ().ToString ());
131138 }
132139 } else if (watchOtherISQuorums && !quorum->IsMember (myProTxHash)) {
@@ -141,13 +148,14 @@ void QuorumParticipant::CheckQuorumConnections(CConnman& connman, const Consensu
141148 connman.SetMasternodeQuorumNodes (llmqParams.type , quorum->m_quorum_base_block_index ->GetBlockHash (), connections);
142149 connman.SetMasternodeQuorumRelayMembers (llmqParams.type , quorum->m_quorum_base_block_index ->GetBlockHash (), connections);
143150 }
144- if (connmanQuorumsToDelete .erase (quorum->qc ->quorumHash ) > 0 ) {
151+ if (deletableQuorums .erase (quorum->qc ->quorumHash ) > 0 ) {
145152 LogPrint (BCLog::LLMQ, " QuorumParticipant::%s -- llmqType[%d] h[%d] keeping mn inter-quorum connections for quorum: [%d:%s]\n " , __func__, ToUnderlying (llmqParams.type ), pindexNew->nHeight , quorum->m_quorum_base_block_index ->nHeight , quorum->m_quorum_base_block_index ->GetBlockHash ().ToString ());
146153 }
147154 }
148155 }
149156 }
150- for (const auto & quorumHash : connmanQuorumsToDelete) {
157+
158+ for (const auto & quorumHash : deletableQuorums) {
151159 LogPrint (BCLog::LLMQ, " QuorumParticipant::%s -- removing masternodes quorum connections for quorum %s:\n " , __func__, quorumHash.ToString ());
152160 connman.RemoveMasternodeQuorumNodes (llmqParams.type , quorumHash);
153161 }
0 commit comments