diff --git a/src/governance.cpp b/src/governance.cpp index 86242a84a..030175645 100644 --- a/src/governance.cpp +++ b/src/governance.cpp @@ -1363,7 +1363,7 @@ void CGovernanceManager::UpdatedBlockTip(const CBlockIndex *pindex, CConnman& co void CGovernanceManager::RequestOrphanObjects(CConnman& connman) { - std::vector vNodesCopy = connman.CopyNodeVector(); + std::vector vNodesCopy = connman.CopyNodeVector(CConnman::FullyConnectedOnly); std::vector vecHashesFiltered; { diff --git a/src/masternode-sync.cpp b/src/masternode-sync.cpp index 3e921d5d1..aeecd8c3e 100644 --- a/src/masternode-sync.cpp +++ b/src/masternode-sync.cpp @@ -179,7 +179,7 @@ void CMasternodeSync::ProcessTick(CConnman& connman) // gradually request the rest of the votes after sync finished if(IsSynced()) { - std::vector vNodesCopy = connman.CopyNodeVector(); + std::vector vNodesCopy = connman.CopyNodeVector(CConnman::FullyConnectedOnly); governance.RequestGovernanceObjectVotes(vNodesCopy, connman); connman.ReleaseNodeVector(vNodesCopy); return; @@ -190,7 +190,7 @@ void CMasternodeSync::ProcessTick(CConnman& connman) LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nRequestedMasternodeAssets %d nRequestedMasternodeAttempt %d nSyncProgress %f\n", nTick, nRequestedMasternodeAssets, nRequestedMasternodeAttempt, nSyncProgress); uiInterface.NotifyAdditionalDataSyncProgressChanged(nSyncProgress); - std::vector vNodesCopy = connman.CopyNodeVector(); + std::vector vNodesCopy = connman.CopyNodeVector(CConnman::FullyConnectedOnly); BOOST_FOREACH(CNode* pnode, vNodesCopy) { diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index cfa183d16..b89284cf8 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -1056,7 +1056,7 @@ bool CMasternodeMan::SendVerifyRequest(const CAddress& addr, const std::vectorGetSendVersion()); + CNetMsgMaker msgMaker(pnode->GetSendVersion()); // TODO this gives a warning about version not being set (we should wait for VERSION exchange) connman.PushMessage(pnode, msgMaker.Make(NetMsgType::MNVERIFY, mnv)); return true; }); diff --git a/src/net.cpp b/src/net.cpp index 49f5899d3..b1f1ee14c 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2841,18 +2841,25 @@ int64_t PoissonNextSend(int64_t nNow, int average_interval_seconds) { return nNow + (int64_t)(log1p(GetRand(1ULL << 48) * -0.0000000000000035527136788 /* -1/2^48 */) * average_interval_seconds * -1000000.0 + 0.5); } -std::vector CConnman::CopyNodeVector() +std::vector CConnman::CopyNodeVector(std::function cond) { std::vector vecNodesCopy; LOCK(cs_vNodes); for(size_t i = 0; i < vNodes.size(); ++i) { CNode* pnode = vNodes[i]; + if (!cond(pnode)) + continue; pnode->AddRef(); vecNodesCopy.push_back(pnode); } return vecNodesCopy; } +std::vector CConnman::CopyNodeVector() +{ + return CopyNodeVector(AllNodes); +} + void CConnman::ReleaseNodeVector(const std::vector& vecNodes) { LOCK(cs_vNodes); diff --git a/src/net.h b/src/net.h index f32b1f36a..606b7808f 100644 --- a/src/net.h +++ b/src/net.h @@ -303,6 +303,7 @@ public: ForEachNodeThen(FullyConnectedOnly, pre, post); } + std::vector CopyNodeVector(std::function cond); std::vector CopyNodeVector(); void ReleaseNodeVector(const std::vector& vecNodes); diff --git a/src/privatesend-client.cpp b/src/privatesend-client.cpp index 4bc0b8348..5f62c0bbf 100644 --- a/src/privatesend-client.cpp +++ b/src/privatesend-client.cpp @@ -889,7 +889,7 @@ bool CPrivateSendClient::JoinExistingQueue(CAmount nBalanceNeedsAnonymized, CCon infoMixingMasternode = infoMn; nSessionDenom = dsq.nDenom; - CNetMsgMaker msgMaker(pnode->GetSendVersion()); + CNetMsgMaker msgMaker(pnode->GetSendVersion()); // TODO this gives a warning about version not being set (we should wait for VERSION exchange) connman.PushMessage(pnode, msgMaker.Make(NetMsgType::DSACCEPT, nSessionDenom, txMyCollateral)); LogPrintf("CPrivateSendClient::JoinExistingQueue -- connected (from queue), sending DSACCEPT: nSessionDenom: %d (%s), addr=%s\n", nSessionDenom, CPrivateSend::GetDenominationsToString(nSessionDenom), pnode->addr.ToString()); @@ -963,7 +963,7 @@ bool CPrivateSendClient::StartNewQueue(CAmount nValueMin, CAmount nBalanceNeedsA nSessionDenom = CPrivateSend::GetDenominationsByAmounts(vecAmounts); } - CNetMsgMaker msgMaker(pnode->GetSendVersion()); + CNetMsgMaker msgMaker(pnode->GetSendVersion()); // TODO this gives a warning about version not being set (we should wait for VERSION exchange) connman.PushMessage(pnode, msgMaker.Make(NetMsgType::DSACCEPT, nSessionDenom, txMyCollateral)); LogPrintf("CPrivateSendClient::StartNewQueue -- connected, sending DSACCEPT, nSessionDenom: %d (%s)\n", nSessionDenom, CPrivateSend::GetDenominationsToString(nSessionDenom)); diff --git a/src/privatesend.cpp b/src/privatesend.cpp index 845cfc661..065cebd02 100644 --- a/src/privatesend.cpp +++ b/src/privatesend.cpp @@ -65,7 +65,7 @@ bool CDarksendQueue::CheckSignature(const CPubKey& pubKeyMasternode) bool CDarksendQueue::Relay(CConnman& connman) { - std::vector vNodesCopy = connman.CopyNodeVector(); + std::vector vNodesCopy = connman.CopyNodeVector(CConnman::FullyConnectedOnly); BOOST_FOREACH(CNode* pnode, vNodesCopy) { CNetMsgMaker msgMaker(pnode->GetSendVersion()); if (pnode->nVersion >= MIN_PRIVATESEND_PEER_PROTO_VERSION)