Skip to content

Commit

Permalink
Take anchor block deeper to avoid "Anchor too new" error
Browse files Browse the repository at this point in the history
  • Loading branch information
Bushstar committed Jun 14, 2021
1 parent cc574a4 commit 51c5f19
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4738,10 +4738,19 @@ void ProcessAuthsIfTipChanged(CBlockIndex const * oldTip, CBlockIndex const * ti
int anchorHeight = static_cast<int>(pindex->height) - consensus.mn.anchoringFrequency;

// Get anchor block from specified time depth
while (anchorHeight > 0 && ::ChainActive()[anchorHeight]->nTime + consensus.mn.anchoringTimeDepth > pindex->nTime) {
int64_t timeDepth = consensus.mn.anchoringTimeDepth;
while (anchorHeight > 0 && ::ChainActive()[anchorHeight]->nTime + timeDepth > pindex->nTime) {
--anchorHeight;
}

// Select a block further back to avoid Anchor too new error.
if (consensus.FortCanningHeight >= tip->height) {
timeDepth += consensus.mn.anchoringTeamChange * consensus.pos.nTargetSpacing;
while (anchorHeight > 0 && ::ChainActive()[anchorHeight]->nTime + timeDepth > pindex->nTime) {
--anchorHeight;
}
}

// Rollback to height consistent with anchoringFrequency
while (anchorHeight > 0 && anchorHeight % consensus.mn.anchoringFrequency != 0) {
--anchorHeight;
Expand Down

0 comments on commit 51c5f19

Please sign in to comment.