Make EnsureQuorumConnections re-set connections in every iteration

Instead of only doing it the first time. This is a preparation for
the new intra-quorum connection system (which connects all members to all
other members)
This commit is contained in:
Alexander Block 2020-03-16 11:06:29 +01:00
parent 9ef1e7cb51
commit 7f1f1d12f5
4 changed files with 8 additions and 11 deletions

View File

@ -193,9 +193,8 @@ void CQuorumManager::EnsureQuorumConnections(Consensus::LLMQType llmqType, const
continue;
}
if (!g_connman->HasMasternodeQuorumNodes(llmqType, quorum->qc.quorumHash)) {
CLLMQUtils::EnsureQuorumConnections(llmqType, quorum->pindexQuorum, myProTxHash, allowWatch);
}
connmanQuorumsToDelete.erase(quorum->qc.quorumHash);
}

View File

@ -127,7 +127,7 @@ void CLLMQUtils::EnsureQuorumConnections(Consensus::LLMQType llmqType, const CBl
}
LogPrint(BCLog::LLMQ, debugMsg.c_str());
}
g_connman->AddMasternodeQuorumNodes(llmqType, pindexQuorum->GetBlockHash(), connections);
g_connman->SetMasternodeQuorumNodes(llmqType, pindexQuorum->GetBlockHash(), connections);
}
}

View File

@ -2797,15 +2797,13 @@ bool CConnman::AddPendingMasternode(const uint256& proTxHash)
return true;
}
bool CConnman::AddMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash, const std::set<uint256>& proTxHashes)
void CConnman::SetMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash, const std::set<uint256>& proTxHashes)
{
LOCK(cs_vPendingMasternodes);
auto it = masternodeQuorumNodes.find(std::make_pair(llmqType, quorumHash));
if (it != masternodeQuorumNodes.end()) {
return false;
auto it = masternodeQuorumNodes.emplace(std::make_pair(llmqType, quorumHash), proTxHashes);
if (!it.second) {
it.first->second = proTxHashes;
}
masternodeQuorumNodes.emplace(std::make_pair(llmqType, quorumHash), proTxHashes);
return true;
}
bool CConnman::HasMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash)

View File

@ -408,7 +408,7 @@ public:
std::vector<AddedNodeInfo> GetAddedNodeInfo();
bool AddPendingMasternode(const uint256& proTxHash);
bool AddMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash, const std::set<uint256>& proTxHashes);
void SetMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash, const std::set<uint256>& proTxHashes);
bool HasMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash);
std::set<uint256> GetMasternodeQuorums(Consensus::LLMQType llmqType);
// also returns QWATCH nodes