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 | |
parent | fa5103a9f5f8559ab005c0b012d3d3a8057d81fb (diff) | |
download | bitcoin-fa2ae373f33fa76dc4e435e7cb4778055aa6afd5.tar.xz |
Add type-safe AdjustedTime() getter to timedata
Also, fix includes.
The getter will be used in a future commit.
-rw-r--r-- | src/addrman_impl.h | 1 | ||||
-rw-r--r-- | src/net_processing.cpp | 1 | ||||
-rw-r--r-- | src/node/interfaces.cpp | 1 | ||||
-rw-r--r-- | src/timedata.h | 8 |
4 files changed, 8 insertions, 3 deletions
diff --git a/src/addrman_impl.h b/src/addrman_impl.h index d675798c03..db3c4560ae 100644 --- a/src/addrman_impl.h +++ b/src/addrman_impl.h @@ -12,6 +12,7 @@ #include <serialize.h> #include <sync.h> #include <uint256.h> +#include <timedata.h> #include <cstdint> #include <optional> diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 74d1bf44d2..c51fe7423e 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -29,6 +29,7 @@ #include <scheduler.h> #include <streams.h> #include <sync.h> +#include <timedata.h> #include <tinyformat.h> #include <txmempool.h> #include <txorphanage.h> diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index be7e3992f0..46d45377fa 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -36,7 +36,6 @@ #include <shutdown.h> #include <support/allocators/secure.h> #include <sync.h> -#include <timedata.h> #include <txmempool.h> #include <uint256.h> #include <univalue.h> 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); /** |