Rework PR to memoize public key on init:

- split PubKeyMsg into PubKeyRequest / PubKeyResponse like other msgs
 - NewRemoteSignerClient sends a pubkey request (once), return this err
 OnStart()
 - NewRemoteSignerClient returns an error if retrieving the pubkey fails
 - remove GetAddress from PrivValidator interface
 - GetPublicKey doesn't err but returns memoized public key from init
 - fix tests
This commit is contained in:
Ismail Khoffi
2018-12-12 13:59:40 +01:00
parent 3d5e06ff7c
commit 3547ce2516
25 changed files with 158 additions and 303 deletions
+3 -12
View File
@@ -240,19 +240,13 @@ func NewNode(config *cfg.Config,
fastSync := config.FastSync
if state.Validators.Size() == 1 {
addr, _ := state.Validators.GetByIndex(0)
privValAddr, err := privValidator.GetAddress()
if err != nil {
return nil, err
}
privValAddr := privValidator.GetPubKey().Address()
if bytes.Equal(privValAddr, addr) {
fastSync = false
}
}
pubKey, err := privValidator.GetPubKey()
if err != nil {
return nil, err
}
pubKey := privValidator.GetPubKey()
addr := pubKey.Address()
// Log whether this node is a validator or an observer
if state.Validators.HasAddress(addr) {
@@ -625,10 +619,7 @@ func (n *Node) ConfigureRPC() {
rpccore.SetEvidencePool(n.evidencePool)
rpccore.SetP2PPeers(n.sw)
rpccore.SetP2PTransport(n)
pubKey, err := n.privValidator.GetPubKey()
if err != nil {
n.Logger.Error("Error configuring RPC", "err", err)
}
pubKey := n.privValidator.GetPubKey()
rpccore.SetPubKey(pubKey)
rpccore.SetGenesisDoc(n.genesisDoc)
rpccore.SetAddrBook(n.addrBook)