Commit d47ff797 authored by Dirk McCormick's avatar Dirk McCormick

Document namesys options

License: MIT
Signed-off-by: default avatarDirk McCormick <dirkmdev@gmail.com>
parent e8f79c88
...@@ -39,26 +39,32 @@ func DefaultResolveOpts() *ResolveOpts { ...@@ -39,26 +39,32 @@ func DefaultResolveOpts() *ResolveOpts {
} }
} }
// ResolveOpt is used to set an option
type ResolveOpt func(*ResolveOpts) type ResolveOpt func(*ResolveOpts)
// Depth is the recursion depth limit
func Depth(depth uint) ResolveOpt { func Depth(depth uint) ResolveOpt {
return func(o *ResolveOpts) { return func(o *ResolveOpts) {
o.Depth = depth o.Depth = depth
} }
} }
// DhtRecordCount is the number of IPNS records to retrieve from the DHT
func DhtRecordCount(count uint) ResolveOpt { func DhtRecordCount(count uint) ResolveOpt {
return func(o *ResolveOpts) { return func(o *ResolveOpts) {
o.DhtRecordCount = count o.DhtRecordCount = count
} }
} }
// 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
func DhtTimeout(timeout time.Duration) ResolveOpt { func DhtTimeout(timeout time.Duration) ResolveOpt {
return func(o *ResolveOpts) { return func(o *ResolveOpts) {
o.DhtTimeout = timeout o.DhtTimeout = timeout
} }
} }
// ProcessOpts converts an array of ResolveOpt into a ResolveOpts object
func ProcessOpts(opts []ResolveOpt) *ResolveOpts { func ProcessOpts(opts []ResolveOpt) *ResolveOpts {
rsopts := DefaultResolveOpts() rsopts := DefaultResolveOpts()
for _, option := range opts { for _, option := range opts {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment