Browse Source

Merge pull request #1197 from tendermint/1155-seed-mode-flag

add seed_mode flag (`--p2p.seed_mode`)
pull/1200/head
Ethan Buchman 7 years ago
committed by GitHub
parent
commit
6b347200d9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 5 deletions
  1. +2
    -1
      CHANGELOG.md
  2. +1
    -0
      cmd/tendermint/commands/run_node.go
  3. +10
    -3
      config/config.go
  4. +9
    -0
      config/toml.go
  5. +9
    -0
      docs/specification/configuration.rst
  6. +1
    -1
      node/node.go

+ 2
- 1
CHANGELOG.md View File

@ -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


+ 1
- 0
cmd/tendermint/commands/run_node.go View File

@ -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")


+ 10
- 3
config/config.go View File

@ -258,9 +258,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"`
@ -275,6 +272,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
@ -289,6 +295,7 @@ func DefaultP2PConfig() *P2PConfig {
SendRate: 512000, // 500 kB/s
RecvRate: 512000, // 500 kB/s
PexReactor: true,
SeedMode: false,
}
}


+ 9
- 0
config/toml.go View File

@ -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]


+ 9
- 0
docs/specification/configuration.rst View File

@ -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]


+ 1
- 1
node/node.go View File

@ -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)
}


Loading…
Cancel
Save