From fa11110bff6288f63e0c487e2e4b4079fb0f4569 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Tue, 8 Dec 2020 16:49:33 +0100 Subject: [PATCH] util: Allow use of C++14 chrono literals --- src/net.h | 4 ++-- src/net_processing.cpp | 2 +- src/randomenv.cpp | 2 +- src/util/time.h | 4 +++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/net.h b/src/net.h index 77aaaac5b14..2fed49540db 100644 --- a/src/net.h +++ b/src/net.h @@ -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 m_last_mempool_req{std::chrono::seconds{0}}; + std::atomic 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 nPingNonceSent{0}; /** When the last ping was sent, or 0 if no ping was ever sent */ - std::atomic m_ping_start{std::chrono::microseconds{0}}; + std::atomic m_ping_start{0us}; // Last measured round-trip time. std::atomic nPingUsecTime{0}; // Best measured round-trip time. diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 2f2924b2628..c46d7d0e617 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -4080,7 +4080,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 5e07c3db408..9248db1539c 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 last_perfmon{std::chrono::seconds{0}}; + static std::atomic last_perfmon{0s}; auto last_time = last_perfmon.load(); auto current_time = GetTime(); if (current_time < last_time + std::chrono::minutes{10}) return; diff --git a/src/util/time.h b/src/util/time.h index af934e423b1..c69f604dc62 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 #include #include -#include + +using namespace std::chrono_literals; void UninterruptibleSleep(const std::chrono::microseconds& n);