feature flag: pex reactor
This commit is contained in:
parent
40f2a128b8
commit
8b80f8ee05
|
@ -19,11 +19,15 @@ func parseFlags(config cfg.Config, args []string) {
|
||||||
logLevel string
|
logLevel string
|
||||||
proxyApp string
|
proxyApp string
|
||||||
tmspTransport string
|
tmspTransport string
|
||||||
|
|
||||||
|
pex bool
|
||||||
)
|
)
|
||||||
|
|
||||||
// Declare flags
|
// Declare flags
|
||||||
var flags = flag.NewFlagSet("main", flag.ExitOnError)
|
var flags = flag.NewFlagSet("main", flag.ExitOnError)
|
||||||
flags.BoolVar(&printHelp, "help", false, "Print this help message.")
|
flags.BoolVar(&printHelp, "help", false, "Print this help message.")
|
||||||
|
|
||||||
|
// configuration options
|
||||||
flags.StringVar(&moniker, "moniker", config.GetString("moniker"), "Node Name")
|
flags.StringVar(&moniker, "moniker", config.GetString("moniker"), "Node Name")
|
||||||
flags.StringVar(&nodeLaddr, "node_laddr", config.GetString("node_laddr"), "Node listen address. (0.0.0.0:0 means any interface, any port)")
|
flags.StringVar(&nodeLaddr, "node_laddr", config.GetString("node_laddr"), "Node listen address. (0.0.0.0:0 means any interface, any port)")
|
||||||
flags.StringVar(&seeds, "seeds", config.GetString("seeds"), "Comma delimited host:port seed nodes")
|
flags.StringVar(&seeds, "seeds", config.GetString("seeds"), "Comma delimited host:port seed nodes")
|
||||||
|
@ -34,6 +38,10 @@ func parseFlags(config cfg.Config, args []string) {
|
||||||
flags.StringVar(&proxyApp, "proxy_app", config.GetString("proxy_app"),
|
flags.StringVar(&proxyApp, "proxy_app", config.GetString("proxy_app"),
|
||||||
"Proxy app address, or 'nilapp' or 'dummy' for local testing.")
|
"Proxy app address, or 'nilapp' or 'dummy' for local testing.")
|
||||||
flags.StringVar(&tmspTransport, "tmsp", config.GetString("tmsp"), "Specify tmsp transport (socket | grpc)")
|
flags.StringVar(&tmspTransport, "tmsp", config.GetString("tmsp"), "Specify tmsp transport (socket | grpc)")
|
||||||
|
|
||||||
|
// feature flags
|
||||||
|
flags.BoolVar(&pex, "pex", config.GetBool("pex_reactor"), "Enable Peer-Exchange (dev feature)")
|
||||||
|
|
||||||
flags.Parse(args)
|
flags.Parse(args)
|
||||||
if printHelp {
|
if printHelp {
|
||||||
flags.PrintDefaults()
|
flags.PrintDefaults()
|
||||||
|
@ -50,4 +58,6 @@ func parseFlags(config cfg.Config, args []string) {
|
||||||
config.Set("log_level", logLevel)
|
config.Set("log_level", logLevel)
|
||||||
config.Set("proxy_app", proxyApp)
|
config.Set("proxy_app", proxyApp)
|
||||||
config.Set("tmsp", tmspTransport)
|
config.Set("tmsp", tmspTransport)
|
||||||
|
|
||||||
|
config.Set("pex_reactor", pex)
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,8 @@ func GetConfig(rootDir string) cfg.Config {
|
||||||
mapConfig.SetDefault("fast_sync", true)
|
mapConfig.SetDefault("fast_sync", true)
|
||||||
mapConfig.SetDefault("skip_upnp", false)
|
mapConfig.SetDefault("skip_upnp", false)
|
||||||
mapConfig.SetDefault("addrbook_file", rootDir+"/addrbook.json")
|
mapConfig.SetDefault("addrbook_file", rootDir+"/addrbook.json")
|
||||||
|
mapConfig.SetDefault("addrbook_strict", true) // disable to allow connections locally
|
||||||
|
mapConfig.SetDefault("pex_reactor", false) // enable for peer exchange
|
||||||
mapConfig.SetDefault("priv_validator_file", rootDir+"/priv_validator.json")
|
mapConfig.SetDefault("priv_validator_file", rootDir+"/priv_validator.json")
|
||||||
mapConfig.SetDefault("db_backend", "leveldb")
|
mapConfig.SetDefault("db_backend", "leveldb")
|
||||||
mapConfig.SetDefault("db_dir", rootDir+"/data")
|
mapConfig.SetDefault("db_dir", rootDir+"/data")
|
||||||
|
|
|
@ -74,6 +74,8 @@ func ResetConfig(localPath string) cfg.Config {
|
||||||
mapConfig.SetDefault("fast_sync", false)
|
mapConfig.SetDefault("fast_sync", false)
|
||||||
mapConfig.SetDefault("skip_upnp", true)
|
mapConfig.SetDefault("skip_upnp", true)
|
||||||
mapConfig.SetDefault("addrbook_file", rootDir+"/addrbook.json")
|
mapConfig.SetDefault("addrbook_file", rootDir+"/addrbook.json")
|
||||||
|
mapConfig.SetDefault("addrbook_strict", true) // disable to allow connections locally
|
||||||
|
mapConfig.SetDefault("pex_reactor", false) // enable for peer exchange
|
||||||
mapConfig.SetDefault("priv_validator_file", rootDir+"/priv_validator.json")
|
mapConfig.SetDefault("priv_validator_file", rootDir+"/priv_validator.json")
|
||||||
mapConfig.SetDefault("db_backend", "memdb")
|
mapConfig.SetDefault("db_backend", "memdb")
|
||||||
mapConfig.SetDefault("db_dir", rootDir+"/data")
|
mapConfig.SetDefault("db_dir", rootDir+"/data")
|
||||||
|
|
|
@ -70,7 +70,7 @@ imports:
|
||||||
- name: github.com/tendermint/go-merkle
|
- name: github.com/tendermint/go-merkle
|
||||||
version: 05042c6ab9cad51d12e4cecf717ae68e3b1409a8
|
version: 05042c6ab9cad51d12e4cecf717ae68e3b1409a8
|
||||||
- name: github.com/tendermint/go-p2p
|
- name: github.com/tendermint/go-p2p
|
||||||
version: 1eb390680d33299ba0e3334490eca587efd18414
|
version: 2cee3646927182964268e63c4248db3def69ac4e
|
||||||
subpackages:
|
subpackages:
|
||||||
- upnp
|
- upnp
|
||||||
- name: github.com/tendermint/go-rpc
|
- name: github.com/tendermint/go-rpc
|
||||||
|
|
|
@ -115,6 +115,15 @@ func NewNode(config cfg.Config, privValidator *types.PrivValidator, clientCreato
|
||||||
sw.AddReactor("BLOCKCHAIN", bcReactor)
|
sw.AddReactor("BLOCKCHAIN", bcReactor)
|
||||||
sw.AddReactor("CONSENSUS", consensusReactor)
|
sw.AddReactor("CONSENSUS", consensusReactor)
|
||||||
|
|
||||||
|
// Optionally, start the pex reactor
|
||||||
|
// TODO: this is a dev feature, it needs some love
|
||||||
|
if config.GetBool("pex_reactor") {
|
||||||
|
addrBook := p2p.NewAddrBook(config.GetString("addrbook_file"), config.GetBool("addrbook_strict"))
|
||||||
|
addrBook.Start()
|
||||||
|
pexReactor := p2p.NewPEXReactor(addrBook)
|
||||||
|
sw.AddReactor("PEX", pexReactor)
|
||||||
|
}
|
||||||
|
|
||||||
// filter peers by addr or pubkey with a tmsp query.
|
// filter peers by addr or pubkey with a tmsp query.
|
||||||
// if the query return code is OK, add peer
|
// if the query return code is OK, add peer
|
||||||
// XXX: query format subject to change
|
// XXX: query format subject to change
|
||||||
|
|
Loading…
Reference in New Issue