mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-13 21:31:23 +00:00
Integrate PrivValidator socket server
This commit is contained in:
@ -14,7 +14,7 @@ func main() {
|
||||
var (
|
||||
chainID = flag.String("chain-id", "mychain", "chain id")
|
||||
listenAddr = flag.String("laddr", ":46659", "Validator listen address (0.0.0.0:0 means any interface, any port")
|
||||
maxClients = flag.Int("clients", 3, "number of concurrently connected clients")
|
||||
maxConn = flag.Int("clients", 3, "maximum of concurrent connections")
|
||||
privValPath = flag.String("priv", "", "priv val file path")
|
||||
|
||||
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "priv_val")
|
||||
@ -25,7 +25,7 @@ func main() {
|
||||
"Starting private validator",
|
||||
"chainID", *chainID,
|
||||
"listenAddr", *listenAddr,
|
||||
"maxClients", *maxClients,
|
||||
"maxConn", *maxConn,
|
||||
"privPath", *privValPath,
|
||||
)
|
||||
|
||||
@ -35,7 +35,7 @@ func main() {
|
||||
logger,
|
||||
*chainID,
|
||||
*listenAddr,
|
||||
*maxClients,
|
||||
*maxConn,
|
||||
privVal,
|
||||
nil,
|
||||
)
|
||||
|
@ -16,6 +16,7 @@ func AddNodeFlags(cmd *cobra.Command) {
|
||||
|
||||
// priv val flags
|
||||
cmd.Flags().String("priv_validator_addr", config.PrivValidatorAddr, "Socket address for private validator")
|
||||
cmd.Flags().Int("priv_validator_max_conn", config.PrivValidatorMaxConn, "Limit of concurrent connections to the PrivValidator")
|
||||
|
||||
// node flags
|
||||
cmd.Flags().Bool("fast_sync", config.FastSync, "Fast blockchain syncing")
|
||||
|
@ -20,7 +20,9 @@ var (
|
||||
|
||||
defaultConfigFileName = "config.toml"
|
||||
defaultGenesisJSONName = "genesis.json"
|
||||
|
||||
defaultPrivValName = "priv_validator.json"
|
||||
defaultPrivValMaxConn = 3
|
||||
defaultNodeKeyName = "node_key.json"
|
||||
defaultAddrBookName = "addrbook.json"
|
||||
|
||||
@ -106,6 +108,9 @@ type BaseConfig struct {
|
||||
// TCP or UNIX socket address of the PrivValidator server
|
||||
PrivValidatorAddr string `mapstructure:"priv_validator_addr"`
|
||||
|
||||
// Limit of concurrent connections to the PrivValidator.
|
||||
PrivValidatorMaxConn int `mapstructure:"priv_validator_max_conn"`
|
||||
|
||||
// TCP or UNIX socket address of the ABCI application,
|
||||
// or the name of an ABCI application compiled in with the Tendermint binary
|
||||
ProxyApp string `mapstructure:"proxy_app"`
|
||||
@ -144,6 +149,7 @@ func DefaultBaseConfig() BaseConfig {
|
||||
return BaseConfig{
|
||||
Genesis: defaultGenesisJSONPath,
|
||||
PrivValidator: defaultPrivValPath,
|
||||
PrivValidatorMaxConn: defaultPrivValMaxConn,
|
||||
NodeKey: defaultNodeKeyPath,
|
||||
Moniker: defaultMoniker,
|
||||
ProxyApp: "tcp://127.0.0.1:46658",
|
||||
|
32
node/node.go
32
node/node.go
@ -34,6 +34,7 @@ import (
|
||||
"github.com/tendermint/tendermint/state/txindex/kv"
|
||||
"github.com/tendermint/tendermint/state/txindex/null"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
priv_val "github.com/tendermint/tendermint/types/priv_validator"
|
||||
"github.com/tendermint/tendermint/version"
|
||||
|
||||
_ "net/http/pprof"
|
||||
@ -77,20 +78,8 @@ type NodeProvider func(*cfg.Config, log.Logger) (*Node, error)
|
||||
// PrivValidator, ClientCreator, GenesisDoc, and DBProvider.
|
||||
// It implements NodeProvider.
|
||||
func DefaultNewNode(config *cfg.Config, logger log.Logger) (*Node, error) {
|
||||
var privVal types.PrivValidator
|
||||
privVal = types.LoadOrGenPrivValidatorFS(config.PrivValidatorFile())
|
||||
/* TODO
|
||||
if config.PrivValidatorAddr != "" {
|
||||
pvsc := priv_val.NewPrivValidatorSocketClient(logger.With("module", "priv_val"),
|
||||
config.PrivValidatorAddr)
|
||||
pvsc.Start()
|
||||
privVal = pvsc
|
||||
}
|
||||
*/
|
||||
fmt.Println("PRIV", config.PrivValidatorAddr)
|
||||
|
||||
return NewNode(config,
|
||||
privVal,
|
||||
types.LoadOrGenPrivValidatorFS(config.PrivValidatorFile()),
|
||||
proxy.DefaultClientCreator(config.ProxyApp, config.ABCI, config.DBDir()),
|
||||
DefaultGenesisDocProviderFunc(config),
|
||||
DefaultDBProvider,
|
||||
@ -184,20 +173,21 @@ func NewNode(config *cfg.Config,
|
||||
// reload the state (it may have been updated by the handshake)
|
||||
state = sm.LoadState(stateDB)
|
||||
|
||||
/* TODO
|
||||
// Generate node PrivKey
|
||||
privKey := crypto.GenPrivKeyEd25519()
|
||||
|
||||
if config.PrivValidatorAddr != "" {
|
||||
pvsc := priv_val.NewPrivValidatorSocketClient(
|
||||
var (
|
||||
privKey = crypto.GenPrivKeyEd25519()
|
||||
pvss = priv_val.NewPrivValidatorSocketServer(
|
||||
logger.With("module", "priv_val"),
|
||||
config.ChainID(),
|
||||
config.PrivValidatorAddr,
|
||||
config.PrivValidatorMaxConn,
|
||||
priv_val.LoadPrivValidatorJSON(config.PrivValidatorFile()),
|
||||
&privKey,
|
||||
)
|
||||
pvsc.Start()
|
||||
privValidator = pvsc
|
||||
)
|
||||
|
||||
pvss.Start()
|
||||
}
|
||||
*/
|
||||
|
||||
// Decide whether to fast-sync or not
|
||||
// We don't fast-sync when the only validator is us.
|
||||
|
Reference in New Issue
Block a user