Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
interface-go-dms3-core
Commits
ca81d824
Commit
ca81d824
authored
Sep 19, 2018
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coreapi name: accept namesys options
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
c3053e81
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
30 deletions
+6
-30
options/name.go
options/name.go
+6
-30
No files found.
options/name.go
View file @
ca81d824
...
...
@@ -2,6 +2,8 @@ package options
import
(
"time"
ropts
"github.com/ipfs/go-ipfs/namesys/opts"
)
const
(
...
...
@@ -14,12 +16,10 @@ type NamePublishSettings struct {
}
type
NameResolveSettings
struct
{
Depth
int
Local
bool
Cache
bool
DhtRecordCount
int
DhtTimeout
time
.
Duration
ResolveOpts
[]
ropts
.
ResolveOpt
}
type
NamePublishOption
func
(
*
NamePublishSettings
)
error
...
...
@@ -43,12 +43,8 @@ func NamePublishOptions(opts ...NamePublishOption) (*NamePublishSettings, error)
func
NameResolveOptions
(
opts
...
NameResolveOption
)
(
*
NameResolveSettings
,
error
)
{
options
:=
&
NameResolveSettings
{
Depth
:
1
,
Local
:
false
,
Cache
:
true
,
DhtRecordCount
:
16
,
DhtTimeout
:
time
.
Minute
,
}
for
_
,
opt
:=
range
opts
{
...
...
@@ -86,15 +82,6 @@ func (nameOpts) Key(key string) NamePublishOption {
}
}
// Depth is an option for Name.Resolve which specifies the maximum depth of a
// recursive lookup. Default value is false
func
(
nameOpts
)
Depth
(
depth
int
)
NameResolveOption
{
return
func
(
settings
*
NameResolveSettings
)
error
{
settings
.
Depth
=
depth
return
nil
}
}
// Local is an option for Name.Resolve which specifies if the lookup should be
// offline. Default value is false
func
(
nameOpts
)
Local
(
local
bool
)
NameResolveOption
{
...
...
@@ -113,21 +100,10 @@ func (nameOpts) Cache(cache bool) NameResolveOption {
}
}
// DhtRecordCount is an option for Name.Resolve which specifies how many records
// we want to validate before selecting the best one (newest). Note that setting
// this value too low will have security implications
func
(
nameOpts
)
DhtRecordCount
(
rc
int
)
NameResolveOption
{
return
func
(
settings
*
NameResolveSettings
)
error
{
settings
.
DhtRecordCount
=
rc
return
nil
}
}
// DhtTimeout is an option for Name.Resolve which specifies timeout for
// DHT lookup
func
(
nameOpts
)
DhtTimeout
(
timeout
time
.
Duration
)
NameResolveOption
{
//
func
(
nameOpts
)
ResolveOption
(
opt
ropts
.
ResolveOpt
)
NameResolveOption
{
return
func
(
settings
*
NameResolveSettings
)
error
{
settings
.
DhtTimeout
=
timeout
settings
.
ResolveOpts
=
append
(
settings
.
ResolveOpts
,
opt
)
return
nil
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment