Skip to content

Commit

Permalink
CBR 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescowens committed Oct 22, 2024
1 parent 6798a9e commit ddebe66
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/gridcoin/staking/reward.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ CAmount GRC::GetConstantBlockReward(const CBlockIndex* index)
CAmount MIN_CBR = 0;
CAmount MAX_CBR = 0;

// GetConstantBlockReward is called with a CBlockIndex pointer as an argument, which means it is expected to
// return the correct value at that position in the chain. The TryActive call in the protocol registry returns
// the CURRENT active value if that exists. This is not what we need if index is not actually pIndexBest.
// Here we find the last protocol entry in the historical linked list of protocol entries for the key "blockreward1"
// that has a timestamp that is less than or equal to the block time. This will filter for the correct historical
// value of blockreward1 that was valid at the index given. One could argue there is some fuzziness here in using
// the block time versus the transaction context time implied by the protocol registry entry; however the actual
// change of CBR must occur on a block boundary anyway, and as long as there is consistent application for consensus
// for V13+ we are safe.
ProtocolEntryOption reward_entry = GetProtocolRegistry().TryLastBeforeTimestamp("blockreward1",
index->GetBlockTime());

Expand Down

0 comments on commit ddebe66

Please sign in to comment.