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,10 +18,11 @@ import (
|
|||
|
||||
const (
|
||||
// peer numbers are arbitrary at the moment.
|
||||
maxPeers = 20
|
||||
maxBlockBatch = 200
|
||||
maxAddrsToSend = 200
|
||||
minPoolCount = 30
|
||||
defaultMinPeers = 5
|
||||
maxPeers = 20
|
||||
maxBlockBatch = 200
|
||||
maxAddrsToSend = 200
|
||||
minPoolCount = 30
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -76,6 +77,14 @@ func NewServer(config ServerConfig, chain core.Blockchainer) *Server {
|
|||
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.discovery = NewDefaultDiscovery(
|
||||
s.DialTimeout,
|
||||
|
|
Loading…
Reference in a new issue