Skip to content

Commit 3b0f8ff

Browse files
committed
Skip mnsync restrictions for whitelisted and manually added nodes (#3249)
1 parent fd94e9c commit 3b0f8ff

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/masternode/masternode-sync.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ void CMasternodeSync::ProcessTick(CConnman& connman)
110110
static int nTick = 0;
111111
nTick++;
112112

113+
const static int64_t nSyncStart = GetTimeMillis();
114+
const static std::string strAllow = strprintf("allow-sync-%lld", nSyncStart);
115+
113116
// reset the sync process if the last call to this function was more than 60 minutes ago (client was in sleep mode)
114117
static int64_t nTimeLastProcess = GetTime();
115118
if(GetTime() - nTimeLastProcess > 60*60) {
@@ -178,6 +181,12 @@ void CMasternodeSync::ProcessTick(CConnman& connman)
178181

179182
// NORMAL NETWORK MODE - TESTNET/MAINNET
180183
{
184+
if ((pnode->fWhitelisted || pnode->m_manual_connection) && !netfulfilledman.HasFulfilledRequest(pnode->addr, strAllow)) {
185+
netfulfilledman.RemoveAllFulfilledRequests(pnode->addr);
186+
netfulfilledman.AddFulfilledRequest(pnode->addr, strAllow);
187+
LogPrintf("CMasternodeSync::ProcessTick -- skipping mnsync restrictions for peer=%d\n", pnode->GetId());
188+
}
189+
181190
if(netfulfilledman.HasFulfilledRequest(pnode->addr, "full-sync")) {
182191
// We already fully synced from this node recently,
183192
// disconnect to free this connection slot for another peer.

src/netfulfilledman.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ void CNetFulfilledRequestManager::RemoveFulfilledRequest(const CService& addr, c
3838
}
3939
}
4040

41+
void CNetFulfilledRequestManager::RemoveAllFulfilledRequests(const CService& addr)
42+
{
43+
LOCK(cs_mapFulfilledRequests);
44+
CService addrSquashed = Params().AllowMultiplePorts() ? addr : CService(addr, 0);
45+
fulfilledreqmap_t::iterator it = mapFulfilledRequests.find(addrSquashed);
46+
47+
if (it != mapFulfilledRequests.end()) {
48+
mapFulfilledRequests.erase(it++);
49+
}
50+
}
51+
4152
void CNetFulfilledRequestManager::CheckAndRemove()
4253
{
4354
LOCK(cs_mapFulfilledRequests);

src/netfulfilledman.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class CNetFulfilledRequestManager
4040
void AddFulfilledRequest(const CService& addr, const std::string& strRequest);
4141
bool HasFulfilledRequest(const CService& addr, const std::string& strRequest);
4242

43+
void RemoveAllFulfilledRequests(const CService& addr);
44+
4345
void CheckAndRemove();
4446
void Clear();
4547

0 commit comments

Comments
 (0)