@@ -140,12 +140,11 @@ void CMasternodeSync::ProcessTick()
140
140
}
141
141
142
142
nTimeLastProcess = GetTime ();
143
- std::vector<CNode*> vNodesCopy = connman. CopyNodeVector ( CConnman::FullyConnectedOnly) ;
143
+ const CConnman::NodesSnapshot snap{connman, /* filter = */ CConnman::FullyConnectedOnly} ;
144
144
145
145
// gradually request the rest of the votes after sync finished
146
146
if (IsSynced ()) {
147
- m_govman.RequestGovernanceObjectVotes (vNodesCopy, connman);
148
- connman.ReleaseNodeVector (vNodesCopy);
147
+ m_govman.RequestGovernanceObjectVotes (snap.Nodes (), connman);
149
148
return ;
150
149
}
151
150
@@ -154,7 +153,7 @@ void CMasternodeSync::ProcessTick()
154
153
LogPrint (BCLog::MNSYNC, " CMasternodeSync::ProcessTick -- nTick %d nCurrentAsset %d nTriedPeerCount %d nSyncProgress %f\n " , nTick, nCurrentAsset, nTriedPeerCount, nSyncProgress);
155
154
uiInterface.NotifyAdditionalDataSyncProgressChanged (nSyncProgress);
156
155
157
- for (auto & pnode : vNodesCopy )
156
+ for (auto & pnode : snap. Nodes () )
158
157
{
159
158
CNetMsgMaker msgMaker (pnode->GetCommonVersion ());
160
159
@@ -189,7 +188,7 @@ void CMasternodeSync::ProcessTick()
189
188
}
190
189
191
190
if (nCurrentAsset == MASTERNODE_SYNC_BLOCKCHAIN) {
192
- int64_t nTimeSyncTimeout = vNodesCopy .size () > 3 ? MASTERNODE_SYNC_TICK_SECONDS : MASTERNODE_SYNC_TIMEOUT_SECONDS;
191
+ int64_t nTimeSyncTimeout = snap. Nodes () .size () > 3 ? MASTERNODE_SYNC_TICK_SECONDS : MASTERNODE_SYNC_TIMEOUT_SECONDS;
193
192
if (fReachedBestHeader && (GetTime () - nTimeLastBumped > nTimeSyncTimeout)) {
194
193
// At this point we know that:
195
194
// a) there are peers (because we are looping on at least one of them);
@@ -205,7 +204,7 @@ void CMasternodeSync::ProcessTick()
205
204
206
205
if (gArgs .GetBoolArg (" -syncmempool" , DEFAULT_SYNC_MEMPOOL)) {
207
206
// Now that the blockchain is synced request the mempool from the connected outbound nodes if possible
208
- for (auto pNodeTmp : vNodesCopy ) {
207
+ for (auto pNodeTmp : snap. Nodes () ) {
209
208
bool fRequestedEarlier = m_netfulfilledman.HasFulfilledRequest (pNodeTmp->addr , " mempool-sync" );
210
209
if (pNodeTmp->nVersion >= 70216 && !pNodeTmp->IsInboundConn () && !fRequestedEarlier && !pNodeTmp->IsBlockRelayOnly ()) {
211
210
m_netfulfilledman.AddFulfilledRequest (pNodeTmp->addr , " mempool-sync" );
@@ -222,7 +221,6 @@ void CMasternodeSync::ProcessTick()
222
221
if (nCurrentAsset == MASTERNODE_SYNC_GOVERNANCE) {
223
222
if (!m_govman.IsValid ()) {
224
223
SwitchToNextAsset ();
225
- connman.ReleaseNodeVector (vNodesCopy);
226
224
return ;
227
225
}
228
226
LogPrint (BCLog::GOBJECT, " CMasternodeSync::ProcessTick -- nTick %d nCurrentAsset %d nTimeLastBumped %lld GetTime() %lld diff %lld\n " , nTick, nCurrentAsset, nTimeLastBumped, GetTime (), GetTime () - nTimeLastBumped);
@@ -235,7 +233,6 @@ void CMasternodeSync::ProcessTick()
235
233
// it's kind of ok to skip this for now, hopefully we'll catch up later?
236
234
}
237
235
SwitchToNextAsset ();
238
- connman.ReleaseNodeVector (vNodesCopy);
239
236
return ;
240
237
}
241
238
@@ -259,12 +256,11 @@ void CMasternodeSync::ProcessTick()
259
256
260
257
if (nCurrentAsset != MASTERNODE_SYNC_GOVERNANCE) {
261
258
// looped through all nodes and not syncing governance yet/already, release them
262
- connman.ReleaseNodeVector (vNodesCopy);
263
259
return ;
264
260
}
265
261
266
262
// request votes on per-obj basis from each node
267
- for (const auto & pnode : vNodesCopy ) {
263
+ for (const auto & pnode : snap. Nodes () ) {
268
264
if (!m_netfulfilledman.HasFulfilledRequest (pnode->addr , " governance-sync" )) {
269
265
continue ; // to early for this node
270
266
}
@@ -291,16 +287,12 @@ void CMasternodeSync::ProcessTick()
291
287
// reset nTimeNoObjectsLeft to be able to use the same condition on resync
292
288
nTimeNoObjectsLeft = 0 ;
293
289
SwitchToNextAsset ();
294
- connman.ReleaseNodeVector (vNodesCopy);
295
290
return ;
296
291
}
297
292
nLastTick = nTick;
298
293
nLastVotes = m_govman.GetVoteCount ();
299
294
}
300
295
}
301
-
302
- // looped through all nodes, release them
303
- connman.ReleaseNodeVector (vNodesCopy);
304
296
}
305
297
306
298
void CMasternodeSync::SendGovernanceSyncRequest (CNode* pnode) const
0 commit comments