diff --git a/include/opendht/network_engine.h b/include/opendht/network_engine.h index cf14c27a..5eeaab5c 100644 --- a/include/opendht/network_engine.h +++ b/include/opendht/network_engine.h @@ -539,7 +539,6 @@ private: std::queue rate_limit_time {}; static std::mt19937 rd_device; - time_point now; // requests handling uint16_t transaction_id {1}; diff --git a/src/network_engine.cpp b/src/network_engine.cpp index c89ca8ab..64f5a3c3 100644 --- a/src/network_engine.cpp +++ b/src/network_engine.cpp @@ -78,13 +78,13 @@ bool NetworkEngine::rateLimit() { using namespace std::chrono; - while (not rate_limit_time.empty() and duration_cast(now - rate_limit_time.front()) > seconds(1)) + while (not rate_limit_time.empty() and duration_cast(scheduler.time() - rate_limit_time.front()) > seconds(1)) rate_limit_time.pop(); if (rate_limit_time.size() >= MAX_REQUESTS_PER_SEC) return false; - rate_limit_time.emplace(now); + rate_limit_time.emplace(scheduler.time()); return true; } @@ -631,11 +631,11 @@ NetworkEngine::sendAnnounceValue(std::shared_ptr n, const InfoHash& infoha msgpack::packer pk(&buffer); pk.pack_map(5); - pk.pack(std::string("a")); pk.pack_map((created < now ? 5 : 4)); + pk.pack(std::string("a")); pk.pack_map((created < scheduler.time() ? 5 : 4)); pk.pack(std::string("id")); pk.pack(myid); pk.pack(std::string("h")); pk.pack(infohash); pk.pack(std::string("values")); pk.pack_array(1); pk.pack(value); - if (created < now) { + if (created < scheduler.time()) { pk.pack(std::string("c")); pk.pack(to_time_t(created)); }