diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-12-09 17:15:00 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-12-09 17:15:11 +0100 |
commit | 7212db4d2a558cf1658cd9173fa4941dcea983cc (patch) | |
tree | e13b9b513575e64b63c3d554e6cd48ba2b46183e /src | |
parent | 42ed7f51fafa9f5de3b4262d28dbb7493c1eeb0f (diff) | |
parent | fa11110bff6288f63e0c487e2e4b4079fb0f4569 (diff) | |
download | bitcoin-7212db4d2a558cf1658cd9173fa4941dcea983cc.tar.xz |
Merge #20602: util: Allow use of C++14 chrono literals
fa11110bff6288f63e0c487e2e4b4079fb0f4569 util: Allow use of C++14 chrono literals (MarcoFalke)
Pull request description:
I think we should allow the use of chrono literals for new code to make it less verbose. Obviously old code can stay as-is.
This patch pulls in the needed namespace and replaces some lines for illustrative purposes.
ACKs for top commit:
vasild:
ACK fa11110bff6288f63e0c487e2e4b4079fb0f4569
jonatack:
ACK fa11110bff6288f63e0c487e2e4b4079fb0f4569
Tree-SHA512: ee2b72c8f28dee07b33b9a8ee8f7c87c0bc43b05c56a17b786cf9803ef204c7628e01b02de1af1a4eb01f5cdf6fc336f69c2833e17acd606ebda20ac6917e6bb
Diffstat (limited to 'src')
-rw-r--r-- | src/net.h | 4 | ||||
-rw-r--r-- | src/net_processing.cpp | 2 | ||||
-rw-r--r-- | src/randomenv.cpp | 2 | ||||
-rw-r--r-- | src/util/time.h | 4 |
4 files changed, 7 insertions, 5 deletions
@@ -1016,7 +1016,7 @@ public: // Used for BIP35 mempool sending bool fSendMempool GUARDED_BY(cs_tx_inventory){false}; // Last time a "MEMPOOL" request was serviced. - std::atomic<std::chrono::seconds> m_last_mempool_req{std::chrono::seconds{0}}; + std::atomic<std::chrono::seconds> m_last_mempool_req{0s}; std::chrono::microseconds nNextInvSend{0}; RecursiveMutex cs_feeFilter; @@ -1049,7 +1049,7 @@ public: // The pong reply we're expecting, or 0 if no pong expected. std::atomic<uint64_t> nPingNonceSent{0}; /** When the last ping was sent, or 0 if no ping was ever sent */ - std::atomic<std::chrono::microseconds> m_ping_start{std::chrono::microseconds{0}}; + std::atomic<std::chrono::microseconds> m_ping_start{0us}; // Last measured round-trip time. std::atomic<int64_t> nPingUsecTime{0}; // Best measured round-trip time. diff --git a/src/net_processing.cpp b/src/net_processing.cpp index b7dd54e55e..443c26605c 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -4057,7 +4057,7 @@ bool PeerManager::SendMessages(CNode* pto) // over since our last self-announcement, but there is only a small // bandwidth cost that we can incur by doing this (which happens // once a day on average). - if (pto->m_next_local_addr_send != std::chrono::microseconds::zero()) { + if (pto->m_next_local_addr_send != 0us) { pto->m_addr_known->reset(); } AdvertiseLocal(pto); diff --git a/src/randomenv.cpp b/src/randomenv.cpp index 5e07c3db40..9248db1539 100644 --- a/src/randomenv.cpp +++ b/src/randomenv.cpp @@ -69,7 +69,7 @@ void RandAddSeedPerfmon(CSHA512& hasher) // This can take up to 2 seconds, so only do it every 10 minutes. // Initialize last_perfmon to 0 seconds, we don't skip the first call. - static std::atomic<std::chrono::seconds> last_perfmon{std::chrono::seconds{0}}; + static std::atomic<std::chrono::seconds> last_perfmon{0s}; auto last_time = last_perfmon.load(); auto current_time = GetTime<std::chrono::seconds>(); if (current_time < last_time + std::chrono::minutes{10}) return; diff --git a/src/util/time.h b/src/util/time.h index af934e423b..c69f604dc6 100644 --- a/src/util/time.h +++ b/src/util/time.h @@ -6,9 +6,11 @@ #ifndef BITCOIN_UTIL_TIME_H #define BITCOIN_UTIL_TIME_H +#include <chrono> #include <stdint.h> #include <string> -#include <chrono> + +using namespace std::chrono_literals; void UninterruptibleSleep(const std::chrono::microseconds& n); |