Browse Source

wip: priv val via sockets

pull/1204/head
Ethan Buchman 7 years ago
parent
commit
23eb84db35
4 changed files with 51 additions and 1 deletions
  1. +32
    -0
      cmd/priv_val_server/main.go
  2. +3
    -0
      cmd/tendermint/commands/run_node.go
  3. +3
    -0
      config/config.go
  4. +13
    -1
      node/node.go

+ 32
- 0
cmd/priv_val_server/main.go View File

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

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

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


+ 3
- 0
config/config.go View File

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


+ 13
- 1
node/node.go View File

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


Loading…
Cancel
Save