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.

Github-Pull: bitcoin#2659
Rebased-From: 34e9c23
  • Loading branch information
furszy committed Dec 14, 2021
1 parent 61477a5 commit 241627c
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 241627c

Please sign in to comment.