Commit 5ad430a7 authored by acud's avatar acud Committed by GitHub

Kademlia: use swarm.MaxBins (#412)

* kademlia: use swarm maxbins
parent 6eedd003
......@@ -5,7 +5,6 @@
package kademlia
var (
MaxBins = maxBins
TimeToRetry = &timeToRetry
SaturationPeers = &saturationPeers
)
......@@ -22,7 +22,6 @@ import (
)
const (
maxBins = 16
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
)
......@@ -86,8 +85,8 @@ func New(o Options) *Kad {
addressBook: o.AddressBook,
p2p: o.P2P,
saturationFunc: o.SaturationFunc,
connectedPeers: pslice.New(maxBins),
knownPeers: pslice.New(maxBins),
connectedPeers: pslice.New(int(swarm.MaxBins)),
knownPeers: pslice.New(int(swarm.MaxBins)),
manageC: make(chan struct{}, 1),
waitNext: make(map[string]retryInfo),
logger: o.Logger,
......@@ -573,7 +572,7 @@ func (k *Kad) marshal(indent bool) ([]byte, error) {
}
var infos []binInfo
for i := (maxBins - 1); i >= 0; i-- {
for i := int(swarm.MaxPO); i >= 0; i-- {
infos = append(infos, binInfo{})
}
......
......@@ -105,7 +105,7 @@ func TestNeighborhoodDepth(t *testing.T) {
kDepth(t, kad, 8)
// 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)
addOne(t, signer, kad, ab, addr)
waitConn(t, &conns)
......
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