Skip to content

Commit fa2ae37

Browse files
author
MarcoFalke
committed
Add type-safe AdjustedTime() getter to timedata
Also, fix includes. The getter will be used in a future commit.
1 parent fa5103a commit fa2ae37

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

src/addrman_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <serialize.h>
1313
#include <sync.h>
1414
#include <uint256.h>
15+
#include <timedata.h>
1516

1617
#include <cstdint>
1718
#include <optional>

src/net_processing.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <scheduler.h>
3030
#include <streams.h>
3131
#include <sync.h>
32+
#include <timedata.h>
3233
#include <tinyformat.h>
3334
#include <txmempool.h>
3435
#include <txorphanage.h>

src/node/interfaces.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include <shutdown.h>
3737
#include <support/allocators/secure.h>
3838
#include <sync.h>
39-
#include <timedata.h>
4039
#include <txmempool.h>
4140
#include <uint256.h>
4241
#include <univalue.h>

src/timedata.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
#ifndef BITCOIN_TIMEDATA_H
66
#define BITCOIN_TIMEDATA_H
77

8+
#include <util/time.h>
9+
810
#include <algorithm>
9-
#include <assert.h>
10-
#include <stdint.h>
11+
#include <cassert>
12+
#include <chrono>
13+
#include <cstdint>
1114
#include <vector>
1215

1316
static const int64_t DEFAULT_MAX_TIME_ADJUSTMENT = 70 * 60;
@@ -73,6 +76,7 @@ class CMedianFilter
7376
/** Functions to keep track of adjusted P2P time */
7477
int64_t GetTimeOffset();
7578
int64_t GetAdjustedTime();
79+
inline NodeSeconds AdjustedTime() { return Now<NodeSeconds>() + std::chrono::seconds{GetTimeOffset()}; }
7680
void AddTimeData(const CNetAddr& ip, int64_t nTime);
7781

7882
/**

0 commit comments

Comments
 (0)