diff --git a/CHANGELOG.md b/CHANGELOG.md index a378f4a0..24f8ae24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,8 +40,9 @@ FEATURES: - [p2p] added new `/dial_peers&persistent=_` **unsafe** endpoint - [p2p] persistent node key in `$THMHOME/config/node_key.json` - [p2p] introduce peer ID and authenticate peers by ID using addresses like `ID@IP:PORT` -- [p2p] new seed mode in pex reactor crawls the network and serves as a seed. TODO: `--p2p.seed_mode` +- [p2p] new seed mode in pex reactor crawls the network and serves as a seed. - [config] MempoolConfig.CacheSize +- [config] P2P.SeedMode (`--p2p.seed_mode`) IMPROVEMENT: - [p2p] stricter rules in the PEX reactor for better handling of abuse diff --git a/cmd/tendermint/commands/run_node.go b/cmd/tendermint/commands/run_node.go index 0eb7a425..76d61671 100644 --- a/cmd/tendermint/commands/run_node.go +++ b/cmd/tendermint/commands/run_node.go @@ -32,6 +32,7 @@ func AddNodeFlags(cmd *cobra.Command) { cmd.Flags().String("p2p.persistent_peers", config.P2P.PersistentPeers, "Comma delimited host:port persistent peers") cmd.Flags().Bool("p2p.skip_upnp", config.P2P.SkipUPNP, "Skip UPNP configuration") cmd.Flags().Bool("p2p.pex", config.P2P.PexReactor, "Enable/disable Peer-Exchange") + cmd.Flags().Bool("p2p.seed_mode", config.P2P.SeedMode, "Enable/disable seed mode") // consensus flags cmd.Flags().Bool("consensus.create_empty_blocks", config.Consensus.CreateEmptyBlocks, "Set this to false to only produce blocks when there are txs or when the AppHash changes") diff --git a/config/config.go b/config/config.go index 6395c60f..abd57311 100644 --- a/config/config.go +++ b/config/config.go @@ -257,9 +257,6 @@ type P2PConfig struct { // Set true for strict address routability rules AddrBookStrict bool `mapstructure:"addr_book_strict"` - // Set true to enable the peer-exchange reactor - PexReactor bool `mapstructure:"pex"` - // Maximum number of peers to connect to MaxNumPeers int `mapstructure:"max_num_peers"` @@ -274,6 +271,15 @@ type P2PConfig struct { // Rate at which packets can be received, in bytes/second RecvRate int64 `mapstructure:"recv_rate"` + + // Set true to enable the peer-exchange reactor + PexReactor bool `mapstructure:"pex"` + + // Seed mode, in which node constantly crawls the network and looks for + // peers. If another node asks it for addresses, it responds and disconnects. + // + // Does not work if the peer-exchange reactor is disabled. + SeedMode bool `mapstructure:"seed_mode"` } // DefaultP2PConfig returns a default configuration for the peer-to-peer layer @@ -288,6 +294,7 @@ func DefaultP2PConfig() *P2PConfig { SendRate: 512000, // 500 kB/s RecvRate: 512000, // 500 kB/s PexReactor: true, + SeedMode: false, } } diff --git a/config/toml.go b/config/toml.go index bdc9f5a6..e69cf37f 100644 --- a/config/toml.go +++ b/config/toml.go @@ -150,6 +150,15 @@ send_rate = {{ .P2P.SendRate }} # Rate at which packets can be received, in bytes/second recv_rate = {{ .P2P.RecvRate }} +# Set true to enable the peer-exchange reactor +pex = {{ .P2P.PexReactor }} + +# Seed mode, in which node constantly crawls the network and looks for +# peers. If another node asks it for addresses, it responds and disconnects. +# +# Does not work if the peer-exchange reactor is disabled. +seed_mode = {{ .P2P.SeedMode }} + ##### mempool configuration options ##### [mempool] diff --git a/docs/specification/configuration.rst b/docs/specification/configuration.rst index cf600290..d7c18600 100644 --- a/docs/specification/configuration.rst +++ b/docs/specification/configuration.rst @@ -112,6 +112,15 @@ like the file below, however, double check by inspecting the # Rate at which packets can be received, in bytes/second recv_rate = 512000 + # Set true to enable the peer-exchange reactor + pex = true + + # Seed mode, in which node constantly crawls the network and looks for + # peers. If another node asks it for addresses, it responds and disconnects. + # + # Does not work if the peer-exchange reactor is disabled. + seed_mode = false + ##### mempool configuration options ##### [mempool] diff --git a/node/node.go b/node/node.go index acf51a90..cd2b4bcb 100644 --- a/node/node.go +++ b/node/node.go @@ -259,7 +259,7 @@ func NewNode(config *cfg.Config, seeds = strings.Split(config.P2P.Seeds, ",") } pexReactor := pex.NewPEXReactor(addrBook, - &pex.PEXReactorConfig{Seeds: seeds}) + &pex.PEXReactorConfig{Seeds: seeds, SeedMode: config.P2P.SeedMode}) pexReactor.SetLogger(p2pLogger) sw.AddReactor("PEX", pexReactor) }