mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-29 14:11:21 +00:00
config: filter_peers defaults to false
This commit is contained in:
parent
943ad0e93f
commit
9bb32f41f1
@ -70,6 +70,7 @@ func GetConfig(rootDir string) cfg.Config {
|
|||||||
mapConfig.SetDefault("revision_file", rootDir+"/revision")
|
mapConfig.SetDefault("revision_file", rootDir+"/revision")
|
||||||
mapConfig.SetDefault("cswal", rootDir+"/data/cswal")
|
mapConfig.SetDefault("cswal", rootDir+"/data/cswal")
|
||||||
mapConfig.SetDefault("cswal_light", false)
|
mapConfig.SetDefault("cswal_light", false)
|
||||||
|
mapConfig.SetDefault("filter_peers", false)
|
||||||
|
|
||||||
mapConfig.SetDefault("block_size", 10000)
|
mapConfig.SetDefault("block_size", 10000)
|
||||||
mapConfig.SetDefault("disable_data_hash", false)
|
mapConfig.SetDefault("disable_data_hash", false)
|
||||||
|
@ -83,6 +83,7 @@ func ResetConfig(localPath string) cfg.Config {
|
|||||||
mapConfig.SetDefault("revision_file", rootDir+"/revision")
|
mapConfig.SetDefault("revision_file", rootDir+"/revision")
|
||||||
mapConfig.SetDefault("cswal", rootDir+"/data/cswal")
|
mapConfig.SetDefault("cswal", rootDir+"/data/cswal")
|
||||||
mapConfig.SetDefault("cswal_light", false)
|
mapConfig.SetDefault("cswal_light", false)
|
||||||
|
mapConfig.SetDefault("filter_peers", false)
|
||||||
|
|
||||||
mapConfig.SetDefault("block_size", 10000)
|
mapConfig.SetDefault("block_size", 10000)
|
||||||
mapConfig.SetDefault("disable_data_hash", false)
|
mapConfig.SetDefault("disable_data_hash", false)
|
||||||
|
39
node/node.go
39
node/node.go
@ -58,8 +58,8 @@ func NewNode(config cfg.Config, privValidator *types.PrivValidator) *Node {
|
|||||||
// Get State
|
// Get State
|
||||||
state := getState(config, stateDB)
|
state := getState(config, stateDB)
|
||||||
|
|
||||||
// Create the proxyApp, which houses two connections,
|
// Create the proxyApp, which houses three connections:
|
||||||
// one for the consensus and one for the mempool.
|
// query, consensus, and mempool
|
||||||
proxyApp := proxy.NewAppConns(config, state, blockStore)
|
proxyApp := proxy.NewAppConns(config, state, blockStore)
|
||||||
|
|
||||||
// add the chainid and number of validators to the global config
|
// add the chainid and number of validators to the global config
|
||||||
@ -112,22 +112,25 @@ func NewNode(config cfg.Config, privValidator *types.PrivValidator) *Node {
|
|||||||
sw.AddReactor("BLOCKCHAIN", bcReactor)
|
sw.AddReactor("BLOCKCHAIN", bcReactor)
|
||||||
sw.AddReactor("CONSENSUS", consensusReactor)
|
sw.AddReactor("CONSENSUS", consensusReactor)
|
||||||
|
|
||||||
// filter peers by addr or pubkey
|
// filter peers by addr or pubkey with a tmsp query.
|
||||||
// NOTE: query format subject to change
|
// if the query return code is OK, add peer
|
||||||
sw.SetAddrFilter(func(addr net.Addr) error {
|
// XXX: query format subject to change
|
||||||
res := proxyApp.Query().QuerySync([]byte(Fmt("p2p/filter/addr/%s", addr.String())))
|
if config.GetBool("filter_peers") {
|
||||||
if res.IsOK() {
|
sw.SetAddrFilter(func(addr net.Addr) error {
|
||||||
return nil
|
res := proxyApp.Query().QuerySync([]byte(Fmt("p2p/filter/addr/%s", addr.String())))
|
||||||
}
|
if res.IsOK() {
|
||||||
return res
|
return nil
|
||||||
})
|
}
|
||||||
sw.SetPubKeyFilter(func(pubkey crypto.PubKeyEd25519) error {
|
return res
|
||||||
res := proxyApp.Query().QuerySync([]byte(Fmt("p2p/filter/pubkey/%X", pubkey.Bytes())))
|
})
|
||||||
if res.IsOK() {
|
sw.SetPubKeyFilter(func(pubkey crypto.PubKeyEd25519) error {
|
||||||
return nil
|
res := proxyApp.Query().QuerySync([]byte(Fmt("p2p/filter/pubkey/%X", pubkey.Bytes())))
|
||||||
}
|
if res.IsOK() {
|
||||||
return res
|
return nil
|
||||||
})
|
}
|
||||||
|
return res
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// add the event switch to all services
|
// add the event switch to all services
|
||||||
// they should all satisfy events.Eventable
|
// they should all satisfy events.Eventable
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
nilapp "github.com/tendermint/tmsp/example/nil"
|
nilapp "github.com/tendermint/tmsp/example/nil"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get a connected tmsp client and perform handshake
|
// Get a connected tmsp client
|
||||||
func NewTMSPClient(addr, transport string) (tmspcli.Client, error) {
|
func NewTMSPClient(addr, transport string) (tmspcli.Client, error) {
|
||||||
var client tmspcli.Client
|
var client tmspcli.Client
|
||||||
|
|
||||||
@ -38,18 +38,6 @@ func NewTMSPClient(addr, transport string) (tmspcli.Client, error) {
|
|||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
func Handshake(config cfg.Config, state State, blockStore BlockStore) {
|
|
||||||
// XXX: Handshake
|
|
||||||
/*res := client.CommitSync()
|
|
||||||
if res.IsErr() {
|
|
||||||
PanicCrisis(Fmt("Error in getting multiAppConnConn hash: %v", res))
|
|
||||||
}
|
|
||||||
if !bytes.Equal(hash, res.Data) {
|
|
||||||
log.Warn(Fmt("ProxyApp hash does not match. Expected %X, got %X", hash, res.Data))
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------
|
//---------
|
||||||
|
|
||||||
type AppConns interface {
|
type AppConns interface {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user