mirror of
https://github.com/libp2p/go-libp2p-peerstore.git
synced 2025-01-06 01:10:09 +08:00
make all TTLs distinct
(also, make permanent TTLs actually permanent)
This commit is contained in:
parent
1a0684bd67
commit
b53dd2e95e
@ -2,6 +2,7 @@ package peerstore
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"math"
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -27,16 +28,19 @@ const (
|
|||||||
|
|
||||||
// OwnObservedAddrTTL is used for our own external addresses observed by peers.
|
// OwnObservedAddrTTL is used for our own external addresses observed by peers.
|
||||||
OwnObservedAddrTTL = time.Minute * 10
|
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)
|
// 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
|
// if we haven't shipped you an update to ipfs in 356 days
|
||||||
// we probably arent running the same bootstrap nodes...
|
// 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
|
// ConnectedAddrTTL is the ttl used for the addresses of a peer to whom
|
||||||
// we're connected directly. This is basically permanent, as we will
|
// we're connected directly. This is basically permanent, as we will
|
||||||
// clear them + re-add under a TempAddrTTL after disconnecting.
|
// clear them + re-add under a TempAddrTTL after disconnecting.
|
||||||
ConnectedAddrTTL = PermanentAddrTTL
|
ConnectedAddrTTL
|
||||||
)
|
)
|
||||||
|
|
||||||
type expiringAddr struct {
|
type expiringAddr struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user