From 5b98b8831b63ef6b79635d9df1bc8291ed47dfd5 Mon Sep 17 00:00:00 2001 From: Pedro Pombeiro Date: Fri, 14 Sep 2018 12:25:52 +0200 Subject: [PATCH] Add peer limits to CLI defaults (#1192) --- params/config.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/params/config.go b/params/config.go index bedb64f98..f191110bf 100644 --- a/params/config.go +++ b/params/config.go @@ -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{