@@ -35,7 +35,7 @@ bool CMasternodeSync::IsBlockchainSynced()
3535 static int64_t lastProcess = GetTime ();
3636
3737 // if the last call to this function was more than 60 minutes ago (client was in sleep mode) reset the sync process
38- if (GetTime () - lastProcess > 60 * 60 ) {
38+ if (GetTime () - lastProcess > GetArg ( " -maxtipage " , 60 * 60 ) ) {
3939 Reset ();
4040 fBlockchainSynced = false ;
4141 }
@@ -52,7 +52,7 @@ bool CMasternodeSync::IsBlockchainSynced()
5252 if (pindex == NULL ) return false ;
5353
5454
55- if (pindex->nTime + 60 * 60 < GetTime ())
55+ if (pindex->nTime + GetArg ( " -maxtipage " , 60 * 60 ) < GetTime ())
5656 return false ;
5757
5858 fBlockchainSynced = true ;
@@ -237,13 +237,13 @@ void CMasternodeSync::Process()
237237 if (tick++ % MASTERNODE_SYNC_TIMEOUT != 0 ) return ;
238238
239239 if (IsSynced ()) {
240- /*
241- Resync if we lose all masternodes from sleep/wake or failure to sync originally
240+ /*
241+ Stay synced once finished. Previously this Reset() every tick whenever there were
242+ 0 enabled masternodes, which on a small/bootstrapping network (legitimately 0 MNs)
243+ caused an endless resync loop so sync never stabilized. New masternodes are still
244+ picked up via normal mnb processing; a restart re-syncs from scratch anyway.
242245 */
243- if (mnodeman.CountEnabled () == 0 ) {
244- Reset ();
245- } else
246- return ;
246+ return ;
247247 }
248248
249249 // try syncing again
@@ -261,6 +261,16 @@ void CMasternodeSync::Process()
261261 if (Params ().NetworkID () != CBaseChainParams::REGTEST &&
262262 !IsBlockchainSynced () && RequestedMasternodeAssets > MASTERNODE_SYNC_SPORKS ) return ;
263263
264+ // Advance the sync asset by time when it stalls. On small/zero-masternode networks no peer
265+ // ever returns LIST/MNW/BUDGET items, and the per-peer "fulfilled request" gating then leaves
266+ // the asset stuck forever (so IsSynced() is never reached). When real data exists the normal
267+ // data-driven transitions above fire well before this timeout, so this only affects the empty case.
268+ if (RequestedMasternodeAssets >= MASTERNODE_SYNC_SPORKS &&
269+ GetTime () - nAssetSyncStarted > MASTERNODE_SYNC_TIMEOUT * 5 ) {
270+ GetNextAsset ();
271+ return ;
272+ }
273+
264274 TRY_LOCK (cs_vNodes, lockRecv);
265275 if (!lockRecv) return ;
266276
0 commit comments