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
p2p
go-p2p-kbucket
Commits
c91e4080
Commit
c91e4080
authored
Feb 28, 2020
by
Aarsh Shah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes as per review
parent
7dd9040c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
3 deletions
+12
-3
options.go
options.go
+2
-2
table.go
table.go
+1
-1
table_test.go
table_test.go
+9
-0
No files found.
options.go
View file @
c91e4080
...
...
@@ -18,8 +18,8 @@ type options struct {
}
}
//
A
pply applies the given options to this option.
func
(
o
*
options
)
A
pply
(
opts
...
Option
)
error
{
//
a
pply applies the given options to this option.
func
(
o
*
options
)
a
pply
(
opts
...
Option
)
error
{
for
i
,
opt
:=
range
opts
{
if
err
:=
opt
(
o
);
err
!=
nil
{
return
fmt
.
Errorf
(
"routing table option %d failed: %s"
,
i
,
err
)
...
...
table.go
View file @
c91e4080
...
...
@@ -90,7 +90,7 @@ func NewRoutingTable(bucketsize int, localID ID, latency time.Duration, m peerst
opts
...
Option
)
(
*
RoutingTable
,
error
)
{
var
cfg
options
if
err
:=
cfg
.
A
pply
(
append
([]
Option
{
Defaults
},
opts
...
)
...
);
err
!=
nil
{
if
err
:=
cfg
.
a
pply
(
append
([]
Option
{
Defaults
},
opts
...
)
...
);
err
!=
nil
{
return
nil
,
err
}
...
...
table_test.go
View file @
c91e4080
...
...
@@ -18,6 +18,15 @@ var PeerAlwaysValidFnc = func(ctx context.Context, p peer.ID) bool {
return
true
}
func
TestPrint
(
t
*
testing
.
T
)
{
t
.
Parallel
()
local
:=
test
.
RandPeerIDFatal
(
t
)
m
:=
pstore
.
NewMetrics
()
rt
,
err
:=
NewRoutingTable
(
1
,
ConvertPeerID
(
local
),
time
.
Hour
,
m
,
PeerValidationFnc
(
PeerAlwaysValidFnc
))
require
.
NoError
(
t
,
err
)
rt
.
Print
()
}
// Test basic features of the bucket struct
func
TestBucket
(
t
*
testing
.
T
)
{
t
.
Parallel
()
...
...
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