From 51eab687d351887d069b70d463f447aabf83d768 Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Tue, 28 Nov 2023 20:47:20 -0500 Subject: [PATCH] add 'is_stale' and 'is_outdated' functions to RouterContact --- llarp/router_contact.cpp | 12 ++++++++++++ llarp/router_contact.hpp | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/llarp/router_contact.cpp b/llarp/router_contact.cpp index 0cd402802..41951e8e8 100644 --- a/llarp/router_contact.cpp +++ b/llarp/router_contact.cpp @@ -248,6 +248,18 @@ namespace llarp return delta > 0s ? delta : 0s; } + bool + RouterContact::is_stale(llarp_time_t now) const + { + return age(now) >= _timestamp.time_since_epoch() + STALE_AGE; + } + + bool + RouterContact::is_outdated(llarp_time_t now) const + { + return age(now) >= _timestamp.time_since_epoch() + OUTDATED_AGE; + } + bool RouterContact::expires_within_delta(llarp_time_t now, llarp_time_t dlt) const { diff --git a/llarp/router_contact.hpp b/llarp/router_contact.hpp index c7a04cd89..a2715f9d6 100644 --- a/llarp/router_contact.hpp +++ b/llarp/router_contact.hpp @@ -194,6 +194,12 @@ namespace llarp llarp_time_t age(llarp_time_t now) const; + bool + is_stale(llarp_time_t now) const; + + bool + is_outdated(llarp_time_t now) const; + bool other_is_newer(const RouterContact& other) const {