Add peer limits to CLI defaults (#1192)

This commit is contained in:
Pedro Pombeiro 2018-09-14 12:25:52 +02:00 committed by GitHub
parent 1ce6f44b5b
commit 5b98b8831b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -304,9 +304,25 @@ func NewNodeConfigWithDefaults(dataDir, fleet string, networkID uint64) (*NodeCo
nodeConfig.WhisperConfig.Enabled = true
nodeConfig.WhisperConfig.EnableNTPSync = true
nodeConfig.updatePeerLimits()
return nodeConfig, nil
}
// updatePeerLimits will set default peer limits expectations based on enabled services.
func (c *NodeConfig) updatePeerLimits() {
if c.NoDiscovery && !c.Rendezvous {
return
}
if c.WhisperConfig.Enabled {
c.RequireTopics[WhisperDiscv5Topic] = WhisperDiscv5Limits
// TODO(dshulyak) register mailserver limits when we will change how they are handled.
}
if c.LightEthConfig.Enabled {
c.RequireTopics[discv5.Topic(LesTopic(int(c.NetworkID)))] = LesDiscoveryLimits
}
}
// NewNodeConfig creates new node configuration object with bare-minimum defaults
func NewNodeConfig(dataDir, fleet string, networkID uint64) (*NodeConfig, error) {
nodeConfig := &NodeConfig{