From 241627cf85bce39fd07b4a9555ecccfc79c89fc9 Mon Sep 17 00:00:00 2001 From: furszy Date: Tue, 7 Dec 2021 21:58:41 -0300 Subject: [PATCH] Budget incremental sync: do not clear seen maps when relay status is reset. The seen maps are used to answer inventory requests (to get the item serialized without locking the main budget maps mutexes). If they are cleared prior to the full budget invs relay, the node will not be able to respond to any follow-up getdata.. Plus, decrease full budget data relay to be done once per week instead of once every 14 days. Github-Pull: #2659 Rebased-From: 34e9c239a7910ec467177d5466f13d3127ede5f4 --- src/budget/budgetmanager.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/budget/budgetmanager.cpp b/src/budget/budgetmanager.cpp index 64b5e32e28d74..0a78b3c5a8cd8 100644 --- a/src/budget/budgetmanager.cpp +++ b/src/budget/budgetmanager.cpp @@ -952,8 +952,8 @@ void CBudgetManager::NewBlock() // incremental sync with our peers if (masternodeSync.IsSynced()) { LogPrint(BCLog::MNBUDGET,"%s: incremental sync started\n", __func__); - if (GetRandInt(1440) == 0) { - ClearSeen(); + // Once every 7 days, try to relay the complete budget data + if (GetRandInt(Params().IsRegTestNet() ? 2 : 720) == 0) { ResetSync(); } @@ -1029,6 +1029,11 @@ void CBudgetManager::NewBlock() // Clean orphan budget votes if no parent arrived after an hour. cleanOrphans(cs_finalizedvotes, mapOrphanFinalizedBudgetVotes, mapSeenFinalizedBudgetVotes); + // Once every 2 weeks (1/14 * 1/1440), clean the seen maps + if (masternodeSync.IsSynced() && GetRandInt(1440) == 0) { + ClearSeen(); + } + LogPrint(BCLog::MNBUDGET,"%s: PASSED\n", __func__); }