diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-12-02 15:24:47 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-12-02 15:24:55 +0100 |
commit | 26a1147ce56083d7aa820ac115c16b01e47d911c (patch) | |
tree | eda1e0c75db53b88aef2bd4c3d94c5d6a1d55b43 /src | |
parent | 0bd7ca9a036ea33397b04cade07d9acc1c31cd30 (diff) | |
parent | fa551b3bdd380bcaa8fa929b378b3b6c81a6f65c (diff) | |
download | bitcoin-26a1147ce56083d7aa820ac115c16b01e47d911c.tar.xz |
Merge bitcoin/bitcoin#23636: Remove GetAdjustedTime from init.cpp
fa551b3bdd380bcaa8fa929b378b3b6c81a6f65c Remove GetAdjustedTime from init.cpp (MarcoFalke)
fa815f8473c56df66302340c5961d18226a60e6f Replace addrman.h include with forward decl in net.h (MarcoFalke)
Pull request description:
It seems confusing to call `GetAdjustedTime` there, because no offset could have been retrieved from the network at this point. Even if connman was started, `timedata` needs at least 5 peer connections to calculate an offset.
Fix the confusion by replacing `GetAdjustedTime` with `GetTime`, which does not change behavior.
Also:
* Replace magic number with `MAX_FUTURE_BLOCK_TIME` to clarify the context
* Add test, which passes both on current master and this pull request
* An unrelated refactoring commit, happy to drop
ACKs for top commit:
dongcarl:
Code Review ACK fa551b3bdd380bcaa8fa929b378b3b6c81a6f65c, noticed the exact same thing here: https://github.com/bitcoin/bitcoin/pull/23280/commits/e073634c37f3a1e140920c6e5e3f2c1ae47cd293
mzumsande:
Code Review ACK fa551b3bdd380bcaa8fa929b378b3b6c81a6f65c
jnewbery:
Code review ACK fa551b3bdd380bcaa8fa929b378b3b6c81a6f65c
shaavan:
ACK fa551b3bdd380bcaa8fa929b378b3b6c81a6f65c
theStack:
Code-review ACK fa551b3bdd380bcaa8fa929b378b3b6c81a6f65c
Tree-SHA512: 15807a0e943e3e8d8c5250c8f6d7b56afb26002b1e290bf93636a2c747f27e78f01f1de04ce1a83d6339e27284c69c43e077a8467545c4078746f4c1ecb1164d
Diffstat (limited to 'src')
-rw-r--r-- | src/init.cpp | 2 | ||||
-rw-r--r-- | src/net.cpp | 1 | ||||
-rw-r--r-- | src/net.h | 6 | ||||
-rw-r--r-- | src/rpc/net.cpp | 1 | ||||
-rw-r--r-- | src/test/fuzz/connman.cpp | 1 |
5 files changed, 7 insertions, 4 deletions
diff --git a/src/init.cpp b/src/init.cpp index d5c3acbaad..22c0d928b5 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1561,7 +1561,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) const CBlockIndex* tip = chainstate->m_chain.Tip(); RPCNotifyBlockChange(tip); - if (tip && tip->nTime > GetAdjustedTime() + 2 * 60 * 60) { + if (tip && tip->nTime > GetTime() + MAX_FUTURE_BLOCK_TIME) { strLoadError = _("The block database contains a block which appears to be from the future. " "This may be due to your computer's date and time being set incorrectly. " "Only rebuild the block database if you are sure that your computer's date and time are correct"); diff --git a/src/net.cpp b/src/net.cpp index e17db7e54b..f6d40a7854 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -10,6 +10,7 @@ #include <net.h> #include <addrdb.h> +#include <addrman.h> #include <banman.h> #include <clientversion.h> #include <compat.h> @@ -6,7 +6,6 @@ #ifndef BITCOIN_NET_H #define BITCOIN_NET_H -#include <addrman.h> #include <chainparams.h> #include <common/bloom.h> #include <compat.h> @@ -37,9 +36,10 @@ #include <thread> #include <vector> -class CScheduler; -class CNode; +class AddrMan; class BanMan; +class CNode; +class CScheduler; struct bilingual_str; /** Default for -whitelistrelay. */ diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index e33f1ce4a3..f4456bebc5 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -4,6 +4,7 @@ #include <rpc/server.h> +#include <addrman.h> #include <banman.h> #include <chainparams.h> #include <clientversion.h> diff --git a/src/test/fuzz/connman.cpp b/src/test/fuzz/connman.cpp index b8f4ad8d94..f87b6f1503 100644 --- a/src/test/fuzz/connman.cpp +++ b/src/test/fuzz/connman.cpp @@ -2,6 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include <addrman.h> #include <chainparams.h> #include <chainparamsbase.h> #include <net.h> |