Browse Source

Integrate privVal client with node secret

pull/1204/head
Alexander Simmerl 7 years ago
committed by Ethan Buchman
parent
commit
7d71e702d8
2 changed files with 30 additions and 11 deletions
  1. +6
    -3
      cmd/priv_val_server/main.go
  2. +24
    -8
      node/node.go

+ 6
- 3
cmd/priv_val_server/main.go View File

@ -13,6 +13,7 @@ import (
func main() { func main() {
var ( var (
chainID = flag.String("chain-id", "mychain", "chain id") chainID = flag.String("chain-id", "mychain", "chain id")
numClients = flag.Int("clients", 1, "number of concurrently connected clients")
privValPath = flag.String("priv", "", "priv val file path") privValPath = flag.String("priv", "", "priv val file path")
socketAddr = flag.String("socket.addr", ":46659", "socket bind addr") socketAddr = flag.String("socket.addr", ":46659", "socket bind addr")
@ -20,17 +21,19 @@ func main() {
) )
flag.Parse() flag.Parse()
logger.Info("args", "chainID", *chainID, "privPath", *privValPath)
logger.Info("Reading args privValidatorSocketServer", "chainID", *chainID, "privPath", *privValPath)
privVal := priv_val.LoadPrivValidatorJSON(*privValPath) privVal := priv_val.LoadPrivValidatorJSON(*privValPath)
pvss := priv_val.NewPrivValidatorSocketServer( pvss := priv_val.NewPrivValidatorSocketServer(
logger, logger,
*socketAddr,
*chainID, *chainID,
*socketAddr,
*numClients,
privVal, privVal,
nil,
) )
// pvss.Start()
pvss.Start()
cmn.TrapSignal(func() { cmn.TrapSignal(func() {
pvss.Stop() pvss.Stop()


+ 24
- 8
node/node.go View File

@ -79,13 +79,13 @@ type NodeProvider func(*cfg.Config, log.Logger) (*Node, error)
func DefaultNewNode(config *cfg.Config, logger log.Logger) (*Node, error) { func DefaultNewNode(config *cfg.Config, logger log.Logger) (*Node, error) {
var privVal types.PrivValidator var privVal types.PrivValidator
privVal = types.LoadOrGenPrivValidatorFS(config.PrivValidatorFile()) privVal = types.LoadOrGenPrivValidatorFS(config.PrivValidatorFile())
/*
if config.PrivValidatorAddr != "" {
pvsc := priv_val.NewPrivValidatorSocketClient(logger.With("module", "priv_val"),
config.PrivValidatorAddr)
pvsc.Start()
privVal = pvsc
}
/* TODO
if config.PrivValidatorAddr != "" {
pvsc := priv_val.NewPrivValidatorSocketClient(logger.With("module", "priv_val"),
config.PrivValidatorAddr)
pvsc.Start()
privVal = pvsc
}
*/ */
fmt.Println("PRIV", config.PrivValidatorAddr) fmt.Println("PRIV", config.PrivValidatorAddr)
@ -94,7 +94,8 @@ func DefaultNewNode(config *cfg.Config, logger log.Logger) (*Node, error) {
proxy.DefaultClientCreator(config.ProxyApp, config.ABCI, config.DBDir()), proxy.DefaultClientCreator(config.ProxyApp, config.ABCI, config.DBDir()),
DefaultGenesisDocProviderFunc(config), DefaultGenesisDocProviderFunc(config),
DefaultDBProvider, DefaultDBProvider,
logger)
logger,
)
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -183,6 +184,21 @@ func NewNode(config *cfg.Config,
// reload the state (it may have been updated by the handshake) // reload the state (it may have been updated by the handshake)
state = sm.LoadState(stateDB) state = sm.LoadState(stateDB)
/* TODO
// Generate node PrivKey
privKey := crypto.GenPrivKeyEd25519()
if config.PrivValidatorAddr != "" {
pvsc := priv_val.NewPrivValidatorSocketClient(
logger.With("module", "priv_val"),
config.PrivValidatorAddr,
&privKey,
)
pvsc.Start()
privValidator = pvsc
}
*/
// Decide whether to fast-sync or not // Decide whether to fast-sync or not
// We don't fast-sync when the only validator is us. // We don't fast-sync when the only validator is us.
fastSync := config.FastSync fastSync := config.FastSync


Loading…
Cancel
Save