Skip to content

Commit e74a704

Browse files
committed
versionbits: Expose StateName function
Rather than essentially duplicating StateName in the unit tests, expose it via the impl header.
1 parent d00d1ed commit e74a704

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

src/test/versionbits_tests.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,6 @@
1616
/* Define a virtual block time, one block per 10 minutes after Nov 14 2014, 0:55:36am */
1717
static int32_t TestTime(int nHeight) { return 1415926536 + 600 * nHeight; }
1818

19-
static std::string StateName(ThresholdState state)
20-
{
21-
switch (state) {
22-
case ThresholdState::DEFINED: return "DEFINED";
23-
case ThresholdState::STARTED: return "STARTED";
24-
case ThresholdState::LOCKED_IN: return "LOCKED_IN";
25-
case ThresholdState::ACTIVE: return "ACTIVE";
26-
case ThresholdState::FAILED: return "FAILED";
27-
} // no default case, so the compiler can warn about missing cases
28-
return "";
29-
}
30-
3119
class TestConditionChecker : public AbstractThresholdConditionChecker
3220
{
3321
private:

src/versionbits.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
using enum ThresholdState;
1313

14-
static std::string StateName(ThresholdState state)
14+
std::string StateName(ThresholdState state)
1515
{
1616
switch (state) {
1717
case DEFINED: return "defined";

src/versionbits_impl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ enum class ThresholdState : uint8_t {
2222
FAILED, // For all blocks once the first retarget period after the timeout time is hit, if LOCKED_IN wasn't already reached (final state)
2323
};
2424

25+
/** Get a string with the state name */
26+
std::string StateName(ThresholdState state);
27+
2528
/**
2629
* Abstract class that implements BIP9-style threshold logic, and caches results.
2730
*/

0 commit comments

Comments
 (0)