From 92f48f360da5f425428b761219301f509826bec4 Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Thu, 11 Mar 2021 12:47:24 +1000 Subject: deploymentinfo: Add DeploymentName() --- src/deploymentinfo.cpp | 18 ++++++++++++++++++ src/deploymentinfo.h | 14 +++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/deploymentinfo.cpp b/src/deploymentinfo.cpp index 70d9961133..030a7806de 100644 --- a/src/deploymentinfo.cpp +++ b/src/deploymentinfo.cpp @@ -16,3 +16,21 @@ const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_B /*.gbt_force =*/ true, }, }; + +std::string DeploymentName(Consensus::BuriedDeployment dep) +{ + assert(ValidDeployment(dep)); + switch (dep) { + case Consensus::DEPLOYMENT_HEIGHTINCB: + return "bip34"; + case Consensus::DEPLOYMENT_CLTV: + return "bip65"; + case Consensus::DEPLOYMENT_DERSIG: + return "bip66"; + case Consensus::DEPLOYMENT_CSV: + return "csv"; + case Consensus::DEPLOYMENT_SEGWIT: + return "segwit"; + } // no default case, so the compiler can warn about missing cases + return ""; +} diff --git a/src/deploymentinfo.h b/src/deploymentinfo.h index 4c68856eac..63d58a7da2 100644 --- a/src/deploymentinfo.h +++ b/src/deploymentinfo.h @@ -5,6 +5,10 @@ #ifndef BITCOIN_DEPLOYMENTINFO_H #define BITCOIN_DEPLOYMENTINFO_H +#include + +#include + struct VBDeploymentInfo { /** Deployment name */ const char *name; @@ -12,6 +16,14 @@ struct VBDeploymentInfo { bool gbt_force; }; -extern const struct VBDeploymentInfo VersionBitsDeploymentInfo[]; +extern const VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS]; + +std::string DeploymentName(Consensus::BuriedDeployment dep); + +inline std::string DeploymentName(Consensus::DeploymentPos pos) +{ + assert(Consensus::ValidDeployment(pos)); + return VersionBitsDeploymentInfo[pos].name; +} #endif // BITCOIN_DEPLOYMENTINFO_H -- cgit v1.2.3