forked from TrueCloudLab/neoneo-go
network: add default MinPeers
If there is nothing specified in the configuration, set it to some reasonable value.
This commit is contained in:
parent
b46dd295bc
commit
e9f8b25776
1 changed files with 13 additions and 4 deletions
|
@ -18,6 +18,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// peer numbers are arbitrary at the moment.
|
// peer numbers are arbitrary at the moment.
|
||||||
|
defaultMinPeers = 5
|
||||||
maxPeers = 20
|
maxPeers = 20
|
||||||
maxBlockBatch = 200
|
maxBlockBatch = 200
|
||||||
maxAddrsToSend = 200
|
maxAddrsToSend = 200
|
||||||
|
@ -76,6 +77,14 @@ func NewServer(config ServerConfig, chain core.Blockchainer) *Server {
|
||||||
peers: make(map[Peer]bool),
|
peers: make(map[Peer]bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.MinPeers <= 0 {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"MinPeers configured": s.MinPeers,
|
||||||
|
"MinPeers actual": defaultMinPeers,
|
||||||
|
}).Info("bad MinPeers configured, using the default value")
|
||||||
|
s.MinPeers = defaultMinPeers
|
||||||
|
}
|
||||||
|
|
||||||
s.transport = NewTCPTransport(s, fmt.Sprintf(":%d", config.ListenTCP))
|
s.transport = NewTCPTransport(s, fmt.Sprintf(":%d", config.ListenTCP))
|
||||||
s.discovery = NewDefaultDiscovery(
|
s.discovery = NewDefaultDiscovery(
|
||||||
s.DialTimeout,
|
s.DialTimeout,
|
||||||
|
|
Loading…
Reference in a new issue