Skip to content

Commit 92f48f3

Browse files
committed
deploymentinfo: Add DeploymentName()
1 parent ea68b3a commit 92f48f3

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/deploymentinfo.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,21 @@ const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_B
1616
/*.gbt_force =*/ true,
1717
},
1818
};
19+
20+
std::string DeploymentName(Consensus::BuriedDeployment dep)
21+
{
22+
assert(ValidDeployment(dep));
23+
switch (dep) {
24+
case Consensus::DEPLOYMENT_HEIGHTINCB:
25+
return "bip34";
26+
case Consensus::DEPLOYMENT_CLTV:
27+
return "bip65";
28+
case Consensus::DEPLOYMENT_DERSIG:
29+
return "bip66";
30+
case Consensus::DEPLOYMENT_CSV:
31+
return "csv";
32+
case Consensus::DEPLOYMENT_SEGWIT:
33+
return "segwit";
34+
} // no default case, so the compiler can warn about missing cases
35+
return "";
36+
}

src/deploymentinfo.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,25 @@
55
#ifndef BITCOIN_DEPLOYMENTINFO_H
66
#define BITCOIN_DEPLOYMENTINFO_H
77

8+
#include <consensus/params.h>
9+
10+
#include <string>
11+
812
struct VBDeploymentInfo {
913
/** Deployment name */
1014
const char *name;
1115
/** Whether GBT clients can safely ignore this rule in simplified usage */
1216
bool gbt_force;
1317
};
1418

15-
extern const struct VBDeploymentInfo VersionBitsDeploymentInfo[];
19+
extern const VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS];
20+
21+
std::string DeploymentName(Consensus::BuriedDeployment dep);
22+
23+
inline std::string DeploymentName(Consensus::DeploymentPos pos)
24+
{
25+
assert(Consensus::ValidDeployment(pos));
26+
return VersionBitsDeploymentInfo[pos].name;
27+
}
1628

1729
#endif // BITCOIN_DEPLOYMENTINFO_H

0 commit comments

Comments
 (0)