What changed, and why it matters
This commit is a minor code cleanup with no security relevance. It adds a named alias 'NodeClock::epoch' for the zero time point and a compile-time check that it equals zero. No behavior changes, no bug fixes, and no security impact.
No action required. This is a benign refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change adds a static constexpr member ‘epoch’ to the NodeClock type and a static_assert verifying that epoch.time_since_epoch().count() == 0. This is purely a readability/refactoring convenience; it does not alter any existing logic, clock behavior, or API surface beyond adding the alias.
Changed components
src/util/time.hsrc/util/time.cppInspect captured patch +3 / −0
diff --git a/src/util/time.cpp b/src/util/time.cpp
index 9e0715e5..1466dc01 100644
--- a/src/util/time.cpp
+++ b/src/util/time.cpp
@@ -27,6 +27,8 @@ static std::atomic<std::chrono::seconds> g_mock_time{}; //!< For testing
std::atomic<bool> g_used_system_time{false};
static std::atomic<MockableSteadyClock::mock_time_point::duration> g_mock_steady_time{}; //!< For testing
+static_assert(NodeClock::epoch.time_since_epoch().count() == 0);
+
NodeClock::time_point NodeClock::now() noexcept
{
const auto mocktime{g_mock_time.load(std::memory_order_relaxed)};
diff --git a/src/util/time.h b/src/util/time.h
index 30d363bb..15d00e80 100644
--- a/src/util/time.h
+++ b/src/util/time.h
@@ -23,6 +23,7 @@ struct NodeClock : public std::chrono::system_clock {
static time_point now() noexcept;
static std::time_t to_time_t(const time_point&) = delete; // unused
static time_point from_time_t(std::time_t) = delete; // unused
+ static constexpr time_point epoch{};
};
using NodeSeconds = std::chrono::time_point<NodeClock, std::chrono::seconds>;
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.