mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Replace CConnman global pointer with local member
This commit is contained in:
parent
12d6597aa7
commit
f90cd9fe37
@ -194,7 +194,7 @@ void CMNAuth::NotifyMasternodeListChanged(bool undo, const CDeterministicMNList&
|
||||
return;
|
||||
}
|
||||
|
||||
g_connman->ForEachNode([&](CNode* pnode) {
|
||||
connman.ForEachNode([&](CNode* pnode) {
|
||||
const auto verifiedProRegTxHash = pnode->GetVerifiedProRegTxHash();
|
||||
if (verifiedProRegTxHash.IsNull()) {
|
||||
return;
|
||||
|
@ -693,7 +693,7 @@ void CQuorumBlockProcessor::AddMineableCommitment(const CFinalCommitment& fqc)
|
||||
// We only relay the new commitment if it's new or better then the old one
|
||||
if (relay) {
|
||||
CInv inv(MSG_QUORUM_FINAL_COMMITMENT, commitmentHash);
|
||||
g_connman->RelayInv(inv);
|
||||
connman.RelayInv(inv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ void CChainLocksHandler::ProcessNewChainLock(const NodeId from, const llmq::CCha
|
||||
|
||||
// Note: do not hold cs while calling RelayInv
|
||||
AssertLockNotHeld(cs);
|
||||
g_connman->RelayInv(clsigInv);
|
||||
connman.RelayInv(clsigInv);
|
||||
|
||||
if (pindex == nullptr) {
|
||||
// we don't know the block/header for this CLSIG yet, so bail out for now
|
||||
|
@ -451,7 +451,7 @@ void CDKGSession::VerifyConnectionAndMinProtoVersions() const
|
||||
CDKGLogger logger(*this, __func__);
|
||||
|
||||
std::unordered_map<uint256, int, StaticSaltedHasher> protoMap;
|
||||
g_connman->ForEachNode([&](const CNode* pnode) {
|
||||
connman.ForEachNode([&](const CNode* pnode) {
|
||||
auto verifiedProRegTxHash = pnode->GetVerifiedProRegTxHash();
|
||||
if (verifiedProRegTxHash.IsNull()) {
|
||||
return;
|
||||
@ -1311,14 +1311,14 @@ void CDKGSession::RelayInvToParticipants(const CInv& inv) const
|
||||
logger.Batch("RelayInvToParticipants inv[%s] relayMembers[%d] GetNodeCount[%d] GetNetworkActive[%d] HasMasternodeQuorumNodes[%d] for quorumHash[%s] forMember[%s] relayMembers[%s]",
|
||||
inv.ToString(),
|
||||
relayMembers.size(),
|
||||
g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL),
|
||||
g_connman->GetNetworkActive(),
|
||||
g_connman->HasMasternodeQuorumNodes(params.type, m_quorum_base_block_index->GetBlockHash()),
|
||||
connman.GetNodeCount(CConnman::CONNECTIONS_ALL),
|
||||
connman.GetNetworkActive(),
|
||||
connman.HasMasternodeQuorumNodes(params.type, m_quorum_base_block_index->GetBlockHash()),
|
||||
m_quorum_base_block_index->GetBlockHash().ToString(),
|
||||
myProTxHash.ToString().substr(0, 4), ss.str());
|
||||
|
||||
std::stringstream ss2;
|
||||
g_connman->ForEachNode([&](CNode* pnode) {
|
||||
connman.ForEachNode([&](CNode* pnode) {
|
||||
if (pnode->qwatch ||
|
||||
(!pnode->GetVerifiedProRegTxHash().IsNull() && relayMembers.count(pnode->GetVerifiedProRegTxHash()))) {
|
||||
pnode->PushInventory(inv);
|
||||
|
@ -1112,11 +1112,11 @@ void CInstantSendManager::ProcessInstantSendLock(NodeId from, const uint256& has
|
||||
const auto is_det = islock->IsDeterministic();
|
||||
CInv inv(is_det ? MSG_ISDLOCK : MSG_ISLOCK, hash);
|
||||
if (tx != nullptr) {
|
||||
g_connman->RelayInvFiltered(inv, *tx, is_det ? ISDLOCK_PROTO_VERSION : MIN_PEER_PROTO_VERSION);
|
||||
connman.RelayInvFiltered(inv, *tx, is_det ? ISDLOCK_PROTO_VERSION : MIN_PEER_PROTO_VERSION);
|
||||
} else {
|
||||
// we don't have the TX yet, so we only filter based on txid. Later when that TX arrives, we will re-announce
|
||||
// with the TX taken into account.
|
||||
g_connman->RelayInvFiltered(inv, islock->txid, is_det ? ISDLOCK_PROTO_VERSION : MIN_PEER_PROTO_VERSION);
|
||||
connman.RelayInvFiltered(inv, islock->txid, is_det ? ISDLOCK_PROTO_VERSION : MIN_PEER_PROTO_VERSION);
|
||||
}
|
||||
|
||||
ResolveBlockConflicts(hash, *islock);
|
||||
@ -1542,11 +1542,11 @@ void CInstantSendManager::AskNodesForLockedTx(const uint256& txid, const CConnma
|
||||
}
|
||||
};
|
||||
|
||||
g_connman->ForEachNode([&](CNode* pnode) {
|
||||
connman.ForEachNode([&](CNode* pnode) {
|
||||
// Check masternodes first
|
||||
if (pnode->m_masternode_connection) maybe_add_to_nodesToAskFor(pnode);
|
||||
});
|
||||
g_connman->ForEachNode([&](CNode* pnode) {
|
||||
connman.ForEachNode([&](CNode* pnode) {
|
||||
// Check non-masternodes next
|
||||
if (!pnode->m_masternode_connection) maybe_add_to_nodesToAskFor(pnode);
|
||||
});
|
||||
|
@ -267,7 +267,7 @@ void CQuorumManager::EnsureQuorumConnections(const Consensus::LLMQParams& llmqPa
|
||||
{
|
||||
auto lastQuorums = ScanQuorums(llmqParams.type, pindexNew, (size_t)llmqParams.keepOldConnections);
|
||||
|
||||
auto connmanQuorumsToDelete = g_connman->GetMasternodeQuorums(llmqParams.type);
|
||||
auto connmanQuorumsToDelete = connman.GetMasternodeQuorums(llmqParams.type);
|
||||
|
||||
// don't remove connections for the currently in-progress DKG round
|
||||
if (CLLMQUtils::IsQuorumRotationEnabled(llmqParams.type, pindexNew)) {
|
||||
@ -296,7 +296,7 @@ void CQuorumManager::EnsureQuorumConnections(const Consensus::LLMQParams& llmqPa
|
||||
}
|
||||
if (connmanQuorumsToDelete.count(quorum->qc->quorumHash) > 0) {
|
||||
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- removing masternodes quorum connections for quorum %s:\n", __func__, quorum->qc->quorumHash.ToString());
|
||||
g_connman->RemoveMasternodeQuorumNodes(llmqParams.type, quorum->qc->quorumHash);
|
||||
connman.RemoveMasternodeQuorumNodes(llmqParams.type, quorum->qc->quorumHash);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -416,7 +416,7 @@ bool CQuorumManager::RequestQuorumData(CNode* pFrom, Consensus::LLMQType llmqTyp
|
||||
}
|
||||
|
||||
CNetMsgMaker msgMaker(pFrom->GetSendVersion());
|
||||
g_connman->PushMessage(pFrom, msgMaker.Make(NetMsgType::QGETDATA, it.first->second));
|
||||
connman.PushMessage(pFrom, msgMaker.Make(NetMsgType::QGETDATA, it.first->second));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -554,7 +554,7 @@ void CQuorumManager::ProcessMessage(CNode* pFrom, const std::string& msg_type, C
|
||||
const CDataStream& body = CDataStream(SER_NETWORK, PROTOCOL_VERSION)) {
|
||||
request.SetError(nError);
|
||||
CDataStream ssResponse(SER_NETWORK, pFrom->GetSendVersion(), request, body);
|
||||
g_connman->PushMessage(pFrom, CNetMsgMaker(pFrom->GetSendVersion()).Make(NetMsgType::QDATA, ssResponse));
|
||||
connman.PushMessage(pFrom, CNetMsgMaker(pFrom->GetSendVersion()).Make(NetMsgType::QDATA, ssResponse));
|
||||
};
|
||||
|
||||
{
|
||||
@ -813,12 +813,12 @@ void CQuorumManager::StartQuorumDataRecoveryThread(const CQuorumCPtr pQuorum, co
|
||||
// Sleep a bit depending on the start offset to balance out multiple requests to same masternode
|
||||
quorumThreadInterrupt.sleep_for(std::chrono::milliseconds(nMyStartOffset * 100));
|
||||
nTimeLastSuccess = GetAdjustedTime();
|
||||
g_connman->AddPendingMasternode(*pCurrentMemberHash);
|
||||
connman.AddPendingMasternode(*pCurrentMemberHash);
|
||||
printLog("Connect");
|
||||
}
|
||||
|
||||
auto proTxHash = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash);
|
||||
g_connman->ForEachNode([&](CNode* pNode) {
|
||||
connman.ForEachNode([&](CNode* pNode) {
|
||||
auto verifiedProRegTxHash = pNode->GetVerifiedProRegTxHash();
|
||||
if (pCurrentMemberHash == nullptr || verifiedProRegTxHash != *pCurrentMemberHash) {
|
||||
return;
|
||||
|
@ -827,7 +827,7 @@ void CSigningManager::ProcessRecoveredSig(const std::shared_ptr<const CRecovered
|
||||
|
||||
if (fMasternodeMode) {
|
||||
CInv inv(MSG_QUORUM_RECOVERED_SIG, recoveredSig->GetHash());
|
||||
g_connman->ForEachNode([&](CNode* pnode) {
|
||||
connman.ForEachNode([&](CNode* pnode) {
|
||||
if (pnode->fSendRecSigs) {
|
||||
pnode->PushInventory(inv);
|
||||
}
|
||||
|
@ -1033,7 +1033,7 @@ void CSigSharesManager::CollectSigSharesToAnnounce(std::unordered_map<NodeId, st
|
||||
auto quorumKey = std::make_pair(sigShare->llmqType, sigShare->quorumHash);
|
||||
auto it = quorumNodesMap.find(quorumKey);
|
||||
if (it == quorumNodesMap.end()) {
|
||||
auto nodeIds = g_connman->GetMasternodeQuorumNodes(quorumKey.first, quorumKey.second);
|
||||
auto nodeIds = connman.GetMasternodeQuorumNodes(quorumKey.first, quorumKey.second);
|
||||
it = quorumNodesMap.emplace(std::piecewise_construct, std::forward_as_tuple(quorumKey), std::forward_as_tuple(nodeIds.begin(), nodeIds.end())).first;
|
||||
}
|
||||
|
||||
@ -1094,7 +1094,7 @@ bool CSigSharesManager::SendMessages()
|
||||
return session->sendSessionId;
|
||||
};
|
||||
|
||||
std::vector<CNode*> vNodesCopy = g_connman->CopyNodeVector(CConnman::FullyConnectedOnly);
|
||||
std::vector<CNode*> vNodesCopy = connman.CopyNodeVector(CConnman::FullyConnectedOnly);
|
||||
|
||||
{
|
||||
LOCK(cs);
|
||||
@ -1133,13 +1133,13 @@ bool CSigSharesManager::SendMessages()
|
||||
CLLMQUtils::BuildSignHash(sigSesAnn).ToString(), sigSesAnn.sessionId, pnode->GetId());
|
||||
msgs.emplace_back(sigSesAnn);
|
||||
if (msgs.size() == MAX_MSGS_CNT_QSIGSESANN) {
|
||||
g_connman->PushMessage(pnode, msgMaker.Make(NetMsgType::QSIGSESANN, msgs));
|
||||
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::QSIGSESANN, msgs));
|
||||
msgs.clear();
|
||||
didSend = true;
|
||||
}
|
||||
}
|
||||
if (!msgs.empty()) {
|
||||
g_connman->PushMessage(pnode, msgMaker.Make(NetMsgType::QSIGSESANN, msgs));
|
||||
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::QSIGSESANN, msgs));
|
||||
didSend = true;
|
||||
}
|
||||
}
|
||||
@ -1152,13 +1152,13 @@ bool CSigSharesManager::SendMessages()
|
||||
signHash.ToString(), inv.ToString(), pnode->GetId());
|
||||
msgs.emplace_back(inv);
|
||||
if (msgs.size() == MAX_MSGS_CNT_QGETSIGSHARES) {
|
||||
g_connman->PushMessage(pnode, msgMaker.Make(NetMsgType::QGETSIGSHARES, msgs));
|
||||
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::QGETSIGSHARES, msgs));
|
||||
msgs.clear();
|
||||
didSend = true;
|
||||
}
|
||||
}
|
||||
if (!msgs.empty()) {
|
||||
g_connman->PushMessage(pnode, msgMaker.Make(NetMsgType::QGETSIGSHARES, msgs));
|
||||
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::QGETSIGSHARES, msgs));
|
||||
didSend = true;
|
||||
}
|
||||
}
|
||||
@ -1171,7 +1171,7 @@ bool CSigSharesManager::SendMessages()
|
||||
LogPrint(BCLog::LLMQ_SIGS, "CSigSharesManager::SendMessages -- QBSIGSHARES signHash=%s, inv={%s}, node=%d\n",
|
||||
signHash.ToString(), inv.ToInvString(), pnode->GetId());
|
||||
if (totalSigsCount + inv.sigShares.size() > MAX_MSGS_TOTAL_BATCHED_SIGS) {
|
||||
g_connman->PushMessage(pnode, msgMaker.Make(NetMsgType::QBSIGSHARES, msgs));
|
||||
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::QBSIGSHARES, msgs));
|
||||
msgs.clear();
|
||||
totalSigsCount = 0;
|
||||
didSend = true;
|
||||
@ -1181,7 +1181,7 @@ bool CSigSharesManager::SendMessages()
|
||||
|
||||
}
|
||||
if (!msgs.empty()) {
|
||||
g_connman->PushMessage(pnode, msgMaker.Make(NetMsgType::QBSIGSHARES, std::move(msgs)));
|
||||
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::QBSIGSHARES, std::move(msgs)));
|
||||
didSend = true;
|
||||
}
|
||||
}
|
||||
@ -1194,13 +1194,13 @@ bool CSigSharesManager::SendMessages()
|
||||
signHash.ToString(), inv.ToString(), pnode->GetId());
|
||||
msgs.emplace_back(inv);
|
||||
if (msgs.size() == MAX_MSGS_CNT_QSIGSHARESINV) {
|
||||
g_connman->PushMessage(pnode, msgMaker.Make(NetMsgType::QSIGSHARESINV, msgs));
|
||||
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::QSIGSHARESINV, msgs));
|
||||
msgs.clear();
|
||||
didSend = true;
|
||||
}
|
||||
}
|
||||
if (!msgs.empty()) {
|
||||
g_connman->PushMessage(pnode, msgMaker.Make(NetMsgType::QSIGSHARESINV, msgs));
|
||||
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::QSIGSHARESINV, msgs));
|
||||
didSend = true;
|
||||
}
|
||||
}
|
||||
@ -1213,20 +1213,20 @@ bool CSigSharesManager::SendMessages()
|
||||
sigShare.GetSignHash().ToString(), pnode->GetId());
|
||||
msgs.emplace_back(std::move(sigShare));
|
||||
if (msgs.size() == MAX_MSGS_SIG_SHARES) {
|
||||
g_connman->PushMessage(pnode, msgMaker.Make(NetMsgType::QSIGSHARE, msgs));
|
||||
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::QSIGSHARE, msgs));
|
||||
msgs.clear();
|
||||
didSend = true;
|
||||
}
|
||||
}
|
||||
if (!msgs.empty()) {
|
||||
g_connman->PushMessage(pnode, msgMaker.Make(NetMsgType::QSIGSHARE, msgs));
|
||||
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::QSIGSHARE, msgs));
|
||||
didSend = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// looped through all nodes, release them
|
||||
g_connman->ReleaseNodeVector(vNodesCopy);
|
||||
connman.ReleaseNodeVector(vNodesCopy);
|
||||
|
||||
return didSend;
|
||||
}
|
||||
@ -1358,7 +1358,7 @@ void CSigSharesManager::Cleanup()
|
||||
nodeStatesToDelete.emplace(nodeId);
|
||||
}
|
||||
}
|
||||
g_connman->ForEachNode([&nodeStatesToDelete](const CNode* pnode) {
|
||||
connman.ForEachNode([&nodeStatesToDelete](const CNode* pnode) {
|
||||
nodeStatesToDelete.erase(pnode->GetId());
|
||||
});
|
||||
|
||||
|
@ -657,7 +657,7 @@ bool CLLMQUtils::EnsureQuorumConnections(const Consensus::LLMQParams& llmqParams
|
||||
relayMembers = connections;
|
||||
}
|
||||
if (!connections.empty()) {
|
||||
if (!g_connman->HasMasternodeQuorumNodes(llmqParams.type, pQuorumBaseBlockIndex->GetBlockHash()) && LogAcceptCategory(BCLog::LLMQ)) {
|
||||
if (!connman.HasMasternodeQuorumNodes(llmqParams.type, pQuorumBaseBlockIndex->GetBlockHash()) && LogAcceptCategory(BCLog::LLMQ)) {
|
||||
auto mnList = deterministicMNManager->GetListAtChainTip();
|
||||
std::string debugMsg = strprintf("CLLMQUtils::%s -- adding masternodes quorum connections for quorum %s:\n", __func__, pQuorumBaseBlockIndex->GetBlockHash().ToString());
|
||||
for (auto& c : connections) {
|
||||
@ -670,10 +670,10 @@ bool CLLMQUtils::EnsureQuorumConnections(const Consensus::LLMQParams& llmqParams
|
||||
}
|
||||
LogPrint(BCLog::NET_NETCONN, debugMsg.c_str()); /* Continued */
|
||||
}
|
||||
g_connman->SetMasternodeQuorumNodes(llmqParams.type, pQuorumBaseBlockIndex->GetBlockHash(), connections);
|
||||
connman.SetMasternodeQuorumNodes(llmqParams.type, pQuorumBaseBlockIndex->GetBlockHash(), connections);
|
||||
}
|
||||
if (!relayMembers.empty()) {
|
||||
g_connman->SetMasternodeQuorumRelayMembers(llmqParams.type, pQuorumBaseBlockIndex->GetBlockHash(), relayMembers);
|
||||
connman.SetMasternodeQuorumRelayMembers(llmqParams.type, pQuorumBaseBlockIndex->GetBlockHash(), relayMembers);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -714,7 +714,7 @@ void CLLMQUtils::AddQuorumProbeConnections(const Consensus::LLMQParams& llmqPara
|
||||
}
|
||||
LogPrint(BCLog::NET_NETCONN, debugMsg.c_str()); /* Continued */
|
||||
}
|
||||
g_connman->AddPendingProbeConnections(probeConnections);
|
||||
connman.AddPendingProbeConnections(probeConnections);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ bool CActiveMasternodeManager::GetLocalAddress(CService& addrRet)
|
||||
bool empty = true;
|
||||
// If we have some peers, let's try to find our local address from one of them
|
||||
auto service = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.service);
|
||||
g_connman->ForEachNodeContinueIf(CConnman::AllNodes, [&](CNode* pnode) {
|
||||
connman.ForEachNodeContinueIf(CConnman::AllNodes, [&](CNode* pnode) {
|
||||
empty = false;
|
||||
if (pnode->addr.IsIPv4())
|
||||
fFoundLocal = GetLocal(service, &pnode->addr) && IsValidNetAddr(service);
|
||||
|
Loading…
Reference in New Issue
Block a user