mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
reintroduce mtx for remote signer calls
This commit is contained in:
parent
5d6f468b2a
commit
7479871402
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
@ -18,6 +19,7 @@ import (
|
|||||||
type RemoteSignerClient struct {
|
type RemoteSignerClient struct {
|
||||||
conn net.Conn
|
conn net.Conn
|
||||||
consensusPubKey crypto.PubKey
|
consensusPubKey crypto.PubKey
|
||||||
|
mtx sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that RemoteSignerClient implements PrivValidator.
|
// Check that RemoteSignerClient implements PrivValidator.
|
||||||
@ -50,6 +52,9 @@ func (sc *RemoteSignerClient) GetAddress() types.Address {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sc *RemoteSignerClient) getPubKey() (crypto.PubKey, error) {
|
func (sc *RemoteSignerClient) getPubKey() (crypto.PubKey, error) {
|
||||||
|
sc.mtx.Lock()
|
||||||
|
defer sc.mtx.Unlock()
|
||||||
|
|
||||||
err := writeMsg(sc.conn, &PubKeyRequest{})
|
err := writeMsg(sc.conn, &PubKeyRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -73,6 +78,9 @@ func (sc *RemoteSignerClient) getPubKey() (crypto.PubKey, error) {
|
|||||||
|
|
||||||
// SignVote implements PrivValidator.
|
// SignVote implements PrivValidator.
|
||||||
func (sc *RemoteSignerClient) SignVote(chainID string, vote *types.Vote) error {
|
func (sc *RemoteSignerClient) SignVote(chainID string, vote *types.Vote) error {
|
||||||
|
sc.mtx.Lock()
|
||||||
|
defer sc.mtx.Unlock()
|
||||||
|
|
||||||
err := writeMsg(sc.conn, &SignVoteRequest{Vote: vote})
|
err := writeMsg(sc.conn, &SignVoteRequest{Vote: vote})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -100,6 +108,9 @@ func (sc *RemoteSignerClient) SignProposal(
|
|||||||
chainID string,
|
chainID string,
|
||||||
proposal *types.Proposal,
|
proposal *types.Proposal,
|
||||||
) error {
|
) error {
|
||||||
|
sc.mtx.Lock()
|
||||||
|
defer sc.mtx.Unlock()
|
||||||
|
|
||||||
err := writeMsg(sc.conn, &SignProposalRequest{Proposal: proposal})
|
err := writeMsg(sc.conn, &SignProposalRequest{Proposal: proposal})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -123,6 +134,9 @@ func (sc *RemoteSignerClient) SignProposal(
|
|||||||
|
|
||||||
// Ping is used to check connection health.
|
// Ping is used to check connection health.
|
||||||
func (sc *RemoteSignerClient) Ping() error {
|
func (sc *RemoteSignerClient) Ping() error {
|
||||||
|
sc.mtx.Lock()
|
||||||
|
defer sc.mtx.Unlock()
|
||||||
|
|
||||||
err := writeMsg(sc.conn, &PingRequest{})
|
err := writeMsg(sc.conn, &PingRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user