return NetworkUpgradeState(nHeight, *this, idx) == UPGRADE_ACTIVE;
}
- int Params::Halvings(int nHeight) const {
+ int Params::Halving(int nHeight) const {
// zip208
// Halving(height) :=
// floor((height - SlowStartShift) / PreBlossomHalvingInterval), if not IsBlossomActivated(height)
// floor((BlossomActivationHeight - SlowStartShift) / PreBlossomHalvingInterval + (height - BlossomActivationHeight) / PostBlossomHalvingInterval), otherwise
if (NetworkUpgradeActive(nHeight, Consensus::UPGRADE_BLOSSOM)) {
- int blossomActivationHeight = vUpgrades[Consensus::UPGRADE_BLOSSOM].nActivationHeight;
+ int64_t blossomActivationHeight = vUpgrades[Consensus::UPGRADE_BLOSSOM].nActivationHeight;
// Ideally we would say:
// halvings = (blossomActivationHeight - consensusParams.SubsidySlowStartShift()) / consensusParams.nPreBlossomSubsidyHalvingInterval
// + (nHeight - blossomActivationHeight) / consensusParams.nPostBlossomSubsidyHalvingInterval;
// But, (blossomActivationHeight - consensusParams.SubsidySlowStartShift()) / consensusParams.nPreBlossomSubsidyHalvingInterval
// would need to be treated as a rational number in order for this to work.
// Define scaledHalvings := halvings * consensusParams.nPostBlossomSubsidyHalvingInterval;
- int scaledHalvings = ((blossomActivationHeight - SubsidySlowStartShift()) * Consensus::BLOSSOM_POW_TARGET_SPACING_RATIO)
+ int64_t scaledHalvings = ((blossomActivationHeight - SubsidySlowStartShift()) * Consensus::BLOSSOM_POW_TARGET_SPACING_RATIO)
+ (nHeight - blossomActivationHeight);
- return scaledHalvings / nPostBlossomSubsidyHalvingInterval;
+ return (int) (scaledHalvings / nPostBlossomSubsidyHalvingInterval);
} else {
return (nHeight - SubsidySlowStartShift()) / nPreBlossomSubsidyHalvingInterval;
}
int nPreBlossomSubsidyHalvingInterval;
int nPostBlossomSubsidyHalvingInterval;
- int Halvings(int nHeight) const;
+ int Halving(int nHeight) const;
int GetLastFoundersRewardBlockHeight(int nHeight) const;
int blossomActivationHeight = Consensus::PRE_BLOSSOM_REGTEST_HALVING_INTERVAL / 2; // = 75
auto params = RegtestActivateBlossom(false, blossomActivationHeight);
int lastFRHeight = params.GetLastFoundersRewardBlockHeight(blossomActivationHeight);
- EXPECT_EQ(0, params.Halvings(lastFRHeight));
- EXPECT_EQ(1, params.Halvings(lastFRHeight + 1));
+ EXPECT_EQ(0, params.Halving(lastFRHeight));
+ EXPECT_EQ(1, params.Halving(lastFRHeight + 1));
RegtestDeactivateBlossom();
}
SelectParams(CBaseChainParams::MAIN);
auto params = Params().GetConsensus();
int lastFRHeight = GetLastFoundersRewardHeight(params);
- EXPECT_EQ(0, params.Halvings(lastFRHeight));
- EXPECT_EQ(1, params.Halvings(lastFRHeight + 1));
+ EXPECT_EQ(0, params.Halving(lastFRHeight));
+ EXPECT_EQ(1, params.Halving(lastFRHeight + 1));
}
#define NUM_MAINNET_FOUNDER_ADDRESSES 48
assert(nHeight > consensusParams.SubsidySlowStartShift());
- int halvings = consensusParams.Halvings(nHeight);
+ int halvings = consensusParams.Halving(nHeight);
// Force block reward to zero when right shift is undefined.
if (halvings >= 64)