Skip to content

Commit

Permalink
versionbits: Expose StateName function
Browse files Browse the repository at this point in the history
Rather than essentially duplicating StateName in the unit tests, expose
it via the impl header.
  • Loading branch information
ajtowns committed Dec 9, 2023
1 parent 1f47d6d commit 11d2b78
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
12 changes: 0 additions & 12 deletions src/test/versionbits_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@
/* 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 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
{
private:
Expand Down
2 changes: 1 addition & 1 deletion src/versionbits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ std::vector<std::pair<int, bool>> VersionBitsCache::CheckUnknownActivations(cons
return result;
}

static std::string StateName(ThresholdState state)
std::string StateName(ThresholdState state)
{
switch (state) {
case ThresholdState::DEFINED: return "defined";
Expand Down
3 changes: 3 additions & 0 deletions src/versionbits_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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)
};

/** Get a string with the state name */
std::string StateName(ThresholdState state);

/**
* Abstract class that implements BIP9-style threshold logic, and caches results.
*/
Expand Down

0 comments on commit 11d2b78

Please sign in to comment.