From b53dd2e95e7b370f5e54af0c250474f2e1af1cc7 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 4 Jan 2018 14:51:36 -0800 Subject: [PATCH] make all TTLs distinct (also, make permanent TTLs actually permanent) --- addr_manager.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addr_manager.go b/addr_manager.go index c7b5b35..0ffa3cf 100644 --- a/addr_manager.go +++ b/addr_manager.go @@ -2,6 +2,7 @@ package peerstore import ( "context" + "math" "sort" "sync" "time" @@ -27,16 +28,19 @@ const ( // OwnObservedAddrTTL is used for our own external addresses observed by peers. OwnObservedAddrTTL = time.Minute * 10 +) +// Perminent TTLs (distinct so we can distinguish between them) +const ( // PermanentAddrTTL is the ttl for a "permanent address" (e.g. bootstrap nodes) // if we haven't shipped you an update to ipfs in 356 days // we probably arent running the same bootstrap nodes... - PermanentAddrTTL = time.Hour * 24 * 356 + PermanentAddrTTL = math.MaxInt64 - iota // ConnectedAddrTTL is the ttl used for the addresses of a peer to whom // we're connected directly. This is basically permanent, as we will // clear them + re-add under a TempAddrTTL after disconnecting. - ConnectedAddrTTL = PermanentAddrTTL + ConnectedAddrTTL ) type expiringAddr struct {