Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
5ad430a7
Unverified
Commit
5ad430a7
authored
Jul 07, 2020
by
acud
Committed by
GitHub
Jul 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kademlia: use swarm.MaxBins (#412)
* kademlia: use swarm maxbins
parent
6eedd003
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
6 deletions
+4
-6
export_test.go
pkg/kademlia/export_test.go
+0
-1
kademlia.go
pkg/kademlia/kademlia.go
+3
-4
kademlia_test.go
pkg/kademlia/kademlia_test.go
+1
-1
No files found.
pkg/kademlia/export_test.go
View file @
5ad430a7
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
package
kademlia
package
kademlia
var
(
var
(
MaxBins
=
maxBins
TimeToRetry
=
&
timeToRetry
TimeToRetry
=
&
timeToRetry
SaturationPeers
=
&
saturationPeers
SaturationPeers
=
&
saturationPeers
)
)
pkg/kademlia/kademlia.go
View file @
5ad430a7
...
@@ -22,7 +22,6 @@ import (
...
@@ -22,7 +22,6 @@ import (
)
)
const
(
const
(
maxBins
=
16
nnLowWatermark
=
2
// the number of peers in consecutive deepest bins that constitute as nearest neighbours
nnLowWatermark
=
2
// the number of peers in consecutive deepest bins that constitute as nearest neighbours
maxConnAttempts
=
3
// when there is maxConnAttempts failed connect calls for a given peer it is considered non-connectable
maxConnAttempts
=
3
// when there is maxConnAttempts failed connect calls for a given peer it is considered non-connectable
)
)
...
@@ -86,8 +85,8 @@ func New(o Options) *Kad {
...
@@ -86,8 +85,8 @@ func New(o Options) *Kad {
addressBook
:
o
.
AddressBook
,
addressBook
:
o
.
AddressBook
,
p2p
:
o
.
P2P
,
p2p
:
o
.
P2P
,
saturationFunc
:
o
.
SaturationFunc
,
saturationFunc
:
o
.
SaturationFunc
,
connectedPeers
:
pslice
.
New
(
maxBins
),
connectedPeers
:
pslice
.
New
(
int
(
swarm
.
MaxBins
)
),
knownPeers
:
pslice
.
New
(
maxBins
),
knownPeers
:
pslice
.
New
(
int
(
swarm
.
MaxBins
)
),
manageC
:
make
(
chan
struct
{},
1
),
manageC
:
make
(
chan
struct
{},
1
),
waitNext
:
make
(
map
[
string
]
retryInfo
),
waitNext
:
make
(
map
[
string
]
retryInfo
),
logger
:
o
.
Logger
,
logger
:
o
.
Logger
,
...
@@ -573,7 +572,7 @@ func (k *Kad) marshal(indent bool) ([]byte, error) {
...
@@ -573,7 +572,7 @@ func (k *Kad) marshal(indent bool) ([]byte, error) {
}
}
var
infos
[]
binInfo
var
infos
[]
binInfo
for
i
:=
(
maxBins
-
1
);
i
>=
0
;
i
--
{
for
i
:=
int
(
swarm
.
MaxPO
);
i
>=
0
;
i
--
{
infos
=
append
(
infos
,
binInfo
{})
infos
=
append
(
infos
,
binInfo
{})
}
}
...
...
pkg/kademlia/kademlia_test.go
View file @
5ad430a7
...
@@ -105,7 +105,7 @@ func TestNeighborhoodDepth(t *testing.T) {
...
@@ -105,7 +105,7 @@ func TestNeighborhoodDepth(t *testing.T) {
kDepth
(
t
,
kad
,
8
)
kDepth
(
t
,
kad
,
8
)
// fill the rest up to the bin before last and check that everything works at the edges
// fill the rest up to the bin before last and check that everything works at the edges
for
i
:=
10
;
i
<
kademlia
.
MaxBins
-
1
;
i
++
{
for
i
:=
10
;
i
<
int
(
swarm
.
MaxBins
)
-
1
;
i
++
{
addr
:=
test
.
RandomAddressAt
(
base
,
i
)
addr
:=
test
.
RandomAddressAt
(
base
,
i
)
addOne
(
t
,
signer
,
kad
,
ab
,
addr
)
addOne
(
t
,
signer
,
kad
,
ab
,
addr
)
waitConn
(
t
,
&
conns
)
waitConn
(
t
,
&
conns
)
...
...
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