PIVX Core  5.6.99
P2P Digital Currency
params.cpp
Go to the documentation of this file.
1 // Copyright (c) 2019 The Zcash developers
2 // Copyright (c) 2020-2021 The PIVX Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or https://www.opensource.org/licenses/mit-license.php .
5 
6 #include "consensus/params.h"
7 #include "consensus/upgrades.h"
8 #include "util/system.h"
9 
10 namespace Consensus {
11 
13 {
15  return error("%s: Upgrade index out of bounds: %d >= %d",
16  __func__, idx, Consensus::MAX_NETWORK_UPGRADES);
17 
18  if (nHeight < 0)
19  return error("%s: Requested state for upgrade %s at negative height %d",
20  __func__, NetworkUpgradeInfo[idx].strName, nHeight);
21 
22  return NetworkUpgradeState(nHeight, *this, idx) == UPGRADE_ACTIVE;
23 }
24 
26 {
27  const auto it = llmqs.find((LLMQType)llmqtype);
28  if (it == llmqs.end()) {
29  return nullopt;
30  }
31  return Optional<LLMQParams>(it->second);
32 }
33 
34 } // End consensus namespace
UpgradeIndex
Index into Params.vUpgrades and NetworkUpgradeInfo.
Definition: params.h:26
@ MAX_NETWORK_UPGRADES
Definition: params.h:44
LLMQType
Definition: params.h:90
boost::optional< T > Optional
Substitute for C++17 std::optional.
Definition: optional.h:12
Optional< LLMQParams > GetLLMQParams(uint8_t llmqtype) const
Definition: params.cpp:25
bool NetworkUpgradeActive(int nHeight, Consensus::UpgradeIndex idx) const
Returns true if the given network upgrade is active as of the given block height.
Definition: params.cpp:12
std::map< LLMQType, LLMQParams > llmqs
Definition: params.h:279
bool error(const char *fmt, const Args &... args)
Definition: system.h:77
UpgradeState NetworkUpgradeState(int nHeight, const Consensus::Params &params, Consensus::UpgradeIndex idx)
Checks the state of a given network upgrade based on block height.
Definition: upgrades.cpp:82
const struct NUInfo NetworkUpgradeInfo[Consensus::MAX_NETWORK_UPGRADES]
General information about each network upgrade.
Definition: upgrades.cpp:15
@ UPGRADE_ACTIVE
Definition: upgrades.h:15