Integrate private validator socket client

Following ADDR 008 the node will connect to an external
process to handle signing requests. Operation of the external process is
left to the user.

* introduce alias for PrivValidator interface on socket client
* integrate socket client in node
* structure tests
* remove unnecessary flag
This commit is contained in:
Alexander Simmerl
2018-02-23 00:40:29 +01:00
parent ffd2483e67
commit 74d3f7e1fd
5 changed files with 233 additions and 191 deletions

View File

@ -173,20 +173,22 @@ func NewNode(config *cfg.Config,
// reload the state (it may have been updated by the handshake)
state = sm.LoadState(stateDB)
// Connect to external signing process, if an address is provided.
if config.PrivValidatorAddr != "" {
var (
privKey = crypto.GenPrivKeyEd25519()
pvss = priv_val.NewPrivValidatorSocketServer(
pvsc = priv_val.NewSocketClient(
logger.With("module", "priv_val"),
config.ChainID(),
config.PrivValidatorAddr,
config.PrivValidatorMaxConn,
priv_val.LoadPrivValidatorJSON(config.PrivValidatorFile()),
&privKey,
)
)
pvss.Start()
if err := pvsc.Start(); err != nil {
return nil, fmt.Errorf("Error starting private validator client: %v", err)
}
privValidator = pvsc
}
// Decide whether to fast-sync or not