Skip to content

Commit

Permalink
increase provider maddr ttl
Browse files Browse the repository at this point in the history
We keep the Multiaddresses of providing peers around for much longer
as this means we'll return them alongside the provider records and
likely make the second DHT lookup for the peer record obsolete.

The assumption is that peers don't change network addresses often.
For context: ipfs/kubo#9264
  • Loading branch information
dennis-tra committed Oct 21, 2022
1 parent dae5a9a commit 75da96a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions providers/providers_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ import (
"github.com/multiformats/go-base32"
)

// ProvidersKeyPrefix is the prefix/namespace for ALL provider record
// keys stored in the data store.
const ProvidersKeyPrefix = "/providers/"
const (
// ProvidersKeyPrefix is the prefix/namespace for ALL provider record
// keys stored in the data store.
ProvidersKeyPrefix = "/providers/"

// ProviderAddrTTL is the TTL to keep the multi addresses of provider
// peers around. This means we return those addresses alongside provider
// records and likely makes the second DHT lookup for addresses obsolete.
ProviderAddrTTL = 24 * time.Hour
)

// ProvideValidity is the default time that a provider record should last
var ProvideValidity = time.Hour * 24
Expand Down Expand Up @@ -232,7 +239,7 @@ func (pm *ProviderManager) run(ctx context.Context, proc goprocess.Process) {
// AddProvider adds a provider
func (pm *ProviderManager) AddProvider(ctx context.Context, k []byte, provInfo peer.AddrInfo) error {
if provInfo.ID != pm.self { // don't add own addrs.
pm.pstore.AddAddrs(provInfo.ID, provInfo.Addrs, peerstore.ProviderAddrTTL)
pm.pstore.AddAddrs(provInfo.ID, provInfo.Addrs, ProviderAddrTTL)
}
prov := &addProv{
ctx: ctx,
Expand Down

0 comments on commit 75da96a

Please sign in to comment.