versionbits: Expose StateName function

Rather than essentially duplicating StateName in the unit tests, expose
it via the impl header.
This commit is contained in:
Anthony Towns 2023-12-09 10:15:15 +10:00
parent d00d1ed52c
commit e74a7049b4
3 changed files with 4 additions and 13 deletions

View file

@ -16,18 +16,6 @@
/* Define a virtual block time, one block per 10 minutes after Nov 14 2014, 0:55:36am */ /* Define a virtual block time, one block per 10 minutes after Nov 14 2014, 0:55:36am */
static int32_t TestTime(int nHeight) { return 1415926536 + 600 * nHeight; } static int32_t TestTime(int nHeight) { return 1415926536 + 600 * nHeight; }
static std::string StateName(ThresholdState state)
{
switch (state) {
case ThresholdState::DEFINED: return "DEFINED";
case ThresholdState::STARTED: return "STARTED";
case ThresholdState::LOCKED_IN: return "LOCKED_IN";
case ThresholdState::ACTIVE: return "ACTIVE";
case ThresholdState::FAILED: return "FAILED";
} // no default case, so the compiler can warn about missing cases
return "";
}
class TestConditionChecker : public AbstractThresholdConditionChecker class TestConditionChecker : public AbstractThresholdConditionChecker
{ {
private: private:

View file

@ -11,7 +11,7 @@
using enum ThresholdState; using enum ThresholdState;
static std::string StateName(ThresholdState state) std::string StateName(ThresholdState state)
{ {
switch (state) { switch (state) {
case DEFINED: return "defined"; case DEFINED: return "defined";

View file

@ -22,6 +22,9 @@ enum class ThresholdState : uint8_t {
FAILED, // For all blocks once the first retarget period after the timeout time is hit, if LOCKED_IN wasn't already reached (final state) FAILED, // For all blocks once the first retarget period after the timeout time is hit, if LOCKED_IN wasn't already reached (final state)
}; };
/** Get a string with the state name */
std::string StateName(ThresholdState state);
/** /**
* Abstract class that implements BIP9-style threshold logic, and caches results. * Abstract class that implements BIP9-style threshold logic, and caches results.
*/ */