diff options
author | MarcoFalke <falke.marco@gmail.com> | 2022-03-24 21:21:58 +0100 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-07-26 11:05:54 +0200 |
commit | fa2ae373f33fa76dc4e435e7cb4778055aa6afd5 (patch) | |
tree | 8b7a69a629e0b273118428eceabf1a57d5e1d2fc /src/timedata.h | |
parent | fa5103a9f5f8559ab005c0b012d3d3a8057d81fb (diff) |
Add type-safe AdjustedTime() getter to timedata
Also, fix includes.
The getter will be used in a future commit.
Diffstat (limited to 'src/timedata.h')
-rw-r--r-- | src/timedata.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/timedata.h b/src/timedata.h index 2f039d5465..ed2d8639f7 100644 --- a/src/timedata.h +++ b/src/timedata.h @@ -5,9 +5,12 @@ #ifndef BITCOIN_TIMEDATA_H #define BITCOIN_TIMEDATA_H +#include <util/time.h> + #include <algorithm> -#include <assert.h> -#include <stdint.h> +#include <cassert> +#include <chrono> +#include <cstdint> #include <vector> static const int64_t DEFAULT_MAX_TIME_ADJUSTMENT = 70 * 60; @@ -73,6 +76,7 @@ public: /** Functions to keep track of adjusted P2P time */ int64_t GetTimeOffset(); int64_t GetAdjustedTime(); +inline NodeSeconds AdjustedTime() { return Now<NodeSeconds>() + std::chrono::seconds{GetTimeOffset()}; } void AddTimeData(const CNetAddr& ip, int64_t nTime); /** |