Skip to content

Commit

Permalink
refactor: dht params to consts
Browse files Browse the repository at this point in the history
This defines the implicit defaults used for every 'ipns name resolve'
DefaultResolverDhtTimeout
DefaultResolverDhtRecordCount
  • Loading branch information
lidel committed Oct 17, 2023
1 parent 0fdcc1f commit c7ca873
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions namesys/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ const (
// complete and can't put an upper limit on how many steps it will take.
UnlimitedDepth = 0

// DefaultResolverRecordCount is the number of IPNS Record copies to
// retrieve from the routing system like Amino DHT (the best record is
// selected from this set).
DefaultResolverDhtRecordCount = 16

// DefaultResolverDhtTimeout is the amount of time to wait for records to be fetched
// and verified.
DefaultResolverDhtTimeout = time.Minute

// DefaultResolverCacheTTL defines default TTL of a record placed in [NameSystem] cache.
DefaultResolverCacheTTL = time.Minute
)
Expand Down Expand Up @@ -100,22 +109,23 @@ type ResolveOptions struct {
// Depth is the recursion depth limit.
Depth uint

// DhtRecordCount is the number of IPNS Records to retrieve from the DHT
// DhtRecordCount is the number of IPNS Records to retrieve from the routing system
// (the best record is selected from this set).
DhtRecordCount uint

// DhtTimeout is the amount of time to wait for DHT records to be fetched
// and verified. A zero value indicates that there is no explicit timeout
// (although there is an implicit timeout due to dial timeouts within the DHT).
// DhtTimeout is the amount of time to wait for records to be fetched and
// verified. A zero value indicates that there is no explicit timeout
// (although there may be an implicit timeout due to dial timeouts within
// the specific routing system like DHT).
DhtTimeout time.Duration
}

// DefaultResolveOptions returns the default options for resolving an IPNS Path.
func DefaultResolveOptions() ResolveOptions {
return ResolveOptions{
Depth: DefaultDepthLimit,
DhtRecordCount: 16,
DhtTimeout: time.Minute,
DhtRecordCount: DefaultResolverDhtRecordCount,
DhtTimeout: DefaultResolverDhtTimeout,
}
}

Expand Down

0 comments on commit c7ca873

Please sign in to comment.