diff --git a/cmd/priv_val_server/main.go b/cmd/priv_val_server/main.go new file mode 100644 index 000000000..651707e83 --- /dev/null +++ b/cmd/priv_val_server/main.go @@ -0,0 +1,32 @@ +package main + +import ( + "flag" + "fmt" + "os" + + cmn "github.com/tendermint/tmlibs/common" + "github.com/tendermint/tmlibs/log" + + priv_val "github.com/tendermint/tendermint/types/priv_validator" +) + +var chainID = flag.String("chain-id", "mychain", "chain id") +var privValPath = flag.String("priv", "", "priv val file path") + +func main() { + flag.Parse() + + logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "priv_val") + socketAddr := "localhost:46659" + fmt.Println(*chainID) + fmt.Println(*privValPath) + privVal := priv_val.LoadPrivValidatorJSON(*privValPath) + + pvss := priv_val.NewPrivValidatorSocketServer(logger, socketAddr, *chainID, privVal) + pvss.Start() + + cmn.TrapSignal(func() { + pvss.Stop() + }) +} diff --git a/cmd/tendermint/commands/run_node.go b/cmd/tendermint/commands/run_node.go index 76d61671d..bebef5edc 100644 --- a/cmd/tendermint/commands/run_node.go +++ b/cmd/tendermint/commands/run_node.go @@ -14,6 +14,9 @@ func AddNodeFlags(cmd *cobra.Command) { // bind flags cmd.Flags().String("moniker", config.Moniker, "Node Name") + // priv val flags + cmd.Flags().String("priv_validator_addr", config.PrivValidatorAddr, "Socket address for PrivValidator") + // node flags cmd.Flags().Bool("fast_sync", config.FastSync, "Fast blockchain syncing") diff --git a/config/config.go b/config/config.go index 621847bd0..6a882185f 100644 --- a/config/config.go +++ b/config/config.go @@ -103,6 +103,9 @@ type BaseConfig struct { // A custom human readable name for this node Moniker string `mapstructure:"moniker"` + // TCP or UNIX socket address of the PrivValidator server + PrivValidatorAddr string `mapstructure:"priv_validator_addr"` + // 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"` diff --git a/node/node.go b/node/node.go index cd2b4bcb5..859cc1df1 100644 --- a/node/node.go +++ b/node/node.go @@ -77,8 +77,20 @@ 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()) + /* + 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, - types.LoadOrGenPrivValidatorFS(config.PrivValidatorFile()), + privVal, proxy.DefaultClientCreator(config.ProxyApp, config.ABCI, config.DBDir()), DefaultGenesisDocProviderFunc(config), DefaultDBProvider,