Extract a helper method for finding the next epoch
This commit is contained in:
@@ -114,20 +114,28 @@ bool IsActivationHeightForAnyUpgrade(
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::optional<int> NextActivationHeight(
|
||||
int nHeight,
|
||||
const Consensus::Params& params)
|
||||
{
|
||||
boost::optional<int> NextEpoch(int nHeight, const Consensus::Params& params) {
|
||||
if (nHeight < 0) {
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
// Don't count Sprout as an activation height
|
||||
// Sprout is never pending
|
||||
for (auto idx = Consensus::BASE_SPROUT + 1; idx < Consensus::MAX_NETWORK_UPGRADES; idx++) {
|
||||
if (NetworkUpgradeState(nHeight, params, Consensus::UpgradeIndex(idx)) == UPGRADE_PENDING) {
|
||||
return params.vUpgrades[idx].nActivationHeight;
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
boost::optional<int> NextActivationHeight(
|
||||
int nHeight,
|
||||
const Consensus::Params& params)
|
||||
{
|
||||
auto idx = NextEpoch(nHeight, params);
|
||||
if (idx) {
|
||||
return params.vUpgrades[idx.get()].nActivationHeight;
|
||||
}
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user