Add method for fetching the next activation height after a given block height
This commit is contained in:
@@ -102,3 +102,21 @@ bool IsActivationHeightForAnyUpgrade(
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::optional<int> NextActivationHeight(
|
||||
int nHeight,
|
||||
const Consensus::Params& params)
|
||||
{
|
||||
if (nHeight < 0) {
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
// Don't count Sprout as an activation height
|
||||
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 boost::none;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "consensus/params.h"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
enum UpgradeState {
|
||||
UPGRADE_DISABLED,
|
||||
UPGRADE_PENDING,
|
||||
@@ -74,4 +76,12 @@ bool IsActivationHeightForAnyUpgrade(
|
||||
int nHeight,
|
||||
const Consensus::Params& params);
|
||||
|
||||
/**
|
||||
* Returns the activation height for the next upgrade after the given block height,
|
||||
* or boost::none if there are no more known upgrades.
|
||||
*/
|
||||
boost::optional<int> NextActivationHeight(
|
||||
int nHeight,
|
||||
const Consensus::Params& params);
|
||||
|
||||
#endif // ZCASH_CONSENSUS_UPGRADES_H
|
||||
|
||||
Reference in New Issue
Block a user