Skip to content

Commit

Permalink
Budget incremental sync: do not clear seen maps when relay status is …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
furszy committed Dec 10, 2021
1 parent fa2ab10 commit 34e9c23
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/budget/budgetmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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__);
}

Expand Down

0 comments on commit 34e9c23

Please sign in to comment.