mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 09:42:22 +00:00
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 (
|
||||
// peer numbers are arbitrary at the moment.
|
||||
defaultMinPeers = 5
|
||||
maxPeers = 20
|
||||
maxBlockBatch = 200
|
||||
maxAddrsToSend = 200
|
||||
|
@ -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