Commit 67cc8f24 authored by metacertain's avatar metacertain Committed by GitHub

param: change binsize (#1729)

parent dc9a129a
...@@ -32,13 +32,13 @@ const ( ...@@ -32,13 +32,13 @@ const (
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
maxBootnodeAttempts = 3 // how many attempts to dial to bootnodes before giving up maxBootnodeAttempts = 3 // how many attempts to dial to bootnodes before giving up
defaultBitSuffixLength = 2 // the number of bits used to create pseudo addresses for balancing defaultBitSuffixLength = 3 // the number of bits used to create pseudo addresses for balancing
peerConnectionAttemptTimeout = 5 * time.Second // Timeout for establishing a new connection with peer. peerConnectionAttemptTimeout = 5 * time.Second // Timeout for establishing a new connection with peer.
) )
var ( var (
saturationPeers = 4 saturationPeers = 8
overSaturationPeers = 16 overSaturationPeers = 16
bootnodeOverSaturationPeers = 64 bootnodeOverSaturationPeers = 64
shortRetry = 30 * time.Second shortRetry = 30 * time.Second
......
...@@ -46,6 +46,11 @@ var nonConnectableAddress, _ = ma.NewMultiaddr(underlayBase + "16Uiu2HAkx8ULY8cT ...@@ -46,6 +46,11 @@ var nonConnectableAddress, _ = ma.NewMultiaddr(underlayBase + "16Uiu2HAkx8ULY8cT
// A more in depth testing of the functionality in `manage()` is explicitly // A more in depth testing of the functionality in `manage()` is explicitly
// tested in TestManage below. // tested in TestManage below.
func TestNeighborhoodDepth(t *testing.T) { func TestNeighborhoodDepth(t *testing.T) {
defer func(p int) {
*kademlia.SaturationPeers = p
}(*kademlia.SaturationPeers)
*kademlia.SaturationPeers = 4
var ( var (
conns int32 // how many connect calls were made to the p2p mock conns int32 // how many connect calls were made to the p2p mock
base, kad, ab, _, signer = newTestKademlia(t, &conns, nil, kademlia.Options{}) base, kad, ab, _, signer = newTestKademlia(t, &conns, nil, kademlia.Options{})
...@@ -306,6 +311,10 @@ func TestManage(t *testing.T) { ...@@ -306,6 +311,10 @@ func TestManage(t *testing.T) {
func TestManageWithBalancing(t *testing.T) { func TestManageWithBalancing(t *testing.T) {
// use "fixed" seed for this // use "fixed" seed for this
defer func(p int) {
*kademlia.SaturationPeers = p
}(*kademlia.SaturationPeers)
*kademlia.SaturationPeers = 4
rand.Seed(2) rand.Seed(2)
var ( var (
...@@ -488,6 +497,11 @@ func TestOversaturationBootnode(t *testing.T) { ...@@ -488,6 +497,11 @@ func TestOversaturationBootnode(t *testing.T) {
}(*kademlia.OverSaturationPeers) }(*kademlia.OverSaturationPeers)
*kademlia.OverSaturationPeers = 4 *kademlia.OverSaturationPeers = 4
defer func(p int) {
*kademlia.SaturationPeers = p
}(*kademlia.SaturationPeers)
*kademlia.SaturationPeers = 4
var ( var (
conns int32 // how many connect calls were made to the p2p mock conns int32 // how many connect calls were made to the p2p mock
base, kad, ab, _, signer = newTestKademlia(t, &conns, nil, kademlia.Options{BootnodeMode: true}) base, kad, ab, _, signer = newTestKademlia(t, &conns, nil, kademlia.Options{BootnodeMode: true})
...@@ -544,6 +558,11 @@ func TestBootnodeMaxConnections(t *testing.T) { ...@@ -544,6 +558,11 @@ func TestBootnodeMaxConnections(t *testing.T) {
}(*kademlia.BootnodeOverSaturationPeers) }(*kademlia.BootnodeOverSaturationPeers)
*kademlia.BootnodeOverSaturationPeers = 4 *kademlia.BootnodeOverSaturationPeers = 4
defer func(p int) {
*kademlia.SaturationPeers = p
}(*kademlia.SaturationPeers)
*kademlia.SaturationPeers = 4
var ( var (
conns int32 // how many connect calls were made to the p2p mock conns int32 // how many connect calls were made to the p2p mock
base, kad, ab, _, signer = newTestKademlia(t, &conns, nil, kademlia.Options{BootnodeMode: true}) base, kad, ab, _, signer = newTestKademlia(t, &conns, nil, kademlia.Options{BootnodeMode: true})
......
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