Skip to content

Commit 59bde8d

Browse files
committed
add_saturation approach in calculateExpirationTime
1 parent a598117 commit 59bde8d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/peer/address_repository/inmem_address_repository.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ namespace libp2p::peer {
6666

6767
Clock::time_point InmemAddressRepository::calculateExpirationTime(
6868
const Milliseconds &ttl) const {
69-
if (ttl >= std::chrono::milliseconds::max() / 2) {
70-
// Handle "permanent" or extremely long TTL values safely
69+
auto now = Clock::now();
70+
if (now >= Clock::time_point::max() - ttl) {
7171
return Clock::time_point::max();
7272
}
73-
return Clock::now() + ttl;
73+
return now + ttl;
7474
}
7575

7676
outcome::result<bool> InmemAddressRepository::addAddresses(

0 commit comments

Comments
 (0)