|
|
@ -41,7 +41,12 @@ func NewSignerClient(ctx context.Context, endpoint *SignerListenerEndpoint, chai |
|
|
|
|
|
|
|
// Close closes the underlying connection
|
|
|
|
func (sc *SignerClient) Close() error { |
|
|
|
return sc.endpoint.Close() |
|
|
|
err := sc.endpoint.Stop() |
|
|
|
cerr := sc.endpoint.Close() |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
return cerr |
|
|
|
} |
|
|
|
|
|
|
|
// IsConnected indicates with the signer is connected to a remote signing service
|
|
|
@ -50,16 +55,16 @@ func (sc *SignerClient) IsConnected() bool { |
|
|
|
} |
|
|
|
|
|
|
|
// WaitForConnection waits maxWait for a connection or returns a timeout error
|
|
|
|
func (sc *SignerClient) WaitForConnection(maxWait time.Duration) error { |
|
|
|
return sc.endpoint.WaitForConnection(maxWait) |
|
|
|
func (sc *SignerClient) WaitForConnection(ctx context.Context, maxWait time.Duration) error { |
|
|
|
return sc.endpoint.WaitForConnection(ctx, maxWait) |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------------------------------
|
|
|
|
// Implement PrivValidator
|
|
|
|
|
|
|
|
// Ping sends a ping request to the remote signer
|
|
|
|
func (sc *SignerClient) Ping() error { |
|
|
|
response, err := sc.endpoint.SendRequest(mustWrapMsg(&privvalproto.PingRequest{})) |
|
|
|
func (sc *SignerClient) Ping(ctx context.Context) error { |
|
|
|
response, err := sc.endpoint.SendRequest(ctx, mustWrapMsg(&privvalproto.PingRequest{})) |
|
|
|
if err != nil { |
|
|
|
sc.logger.Error("SignerClient::Ping", "err", err) |
|
|
|
return nil |
|
|
@ -76,7 +81,7 @@ func (sc *SignerClient) Ping() error { |
|
|
|
// GetPubKey retrieves a public key from a remote signer
|
|
|
|
// returns an error if client is not able to provide the key
|
|
|
|
func (sc *SignerClient) GetPubKey(ctx context.Context) (crypto.PubKey, error) { |
|
|
|
response, err := sc.endpoint.SendRequest(mustWrapMsg(&privvalproto.PubKeyRequest{ChainId: sc.chainID})) |
|
|
|
response, err := sc.endpoint.SendRequest(ctx, mustWrapMsg(&privvalproto.PubKeyRequest{ChainId: sc.chainID})) |
|
|
|
if err != nil { |
|
|
|
return nil, fmt.Errorf("send: %w", err) |
|
|
|
} |
|
|
@ -99,7 +104,7 @@ func (sc *SignerClient) GetPubKey(ctx context.Context) (crypto.PubKey, error) { |
|
|
|
|
|
|
|
// SignVote requests a remote signer to sign a vote
|
|
|
|
func (sc *SignerClient) SignVote(ctx context.Context, chainID string, vote *tmproto.Vote) error { |
|
|
|
response, err := sc.endpoint.SendRequest(mustWrapMsg(&privvalproto.SignVoteRequest{Vote: vote, ChainId: chainID})) |
|
|
|
response, err := sc.endpoint.SendRequest(ctx, mustWrapMsg(&privvalproto.SignVoteRequest{Vote: vote, ChainId: chainID})) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
@ -119,7 +124,7 @@ func (sc *SignerClient) SignVote(ctx context.Context, chainID string, vote *tmpr |
|
|
|
|
|
|
|
// SignProposal requests a remote signer to sign a proposal
|
|
|
|
func (sc *SignerClient) SignProposal(ctx context.Context, chainID string, proposal *tmproto.Proposal) error { |
|
|
|
response, err := sc.endpoint.SendRequest(mustWrapMsg( |
|
|
|
response, err := sc.endpoint.SendRequest(ctx, mustWrapMsg( |
|
|
|
&privvalproto.SignProposalRequest{Proposal: proposal, ChainId: chainID}, |
|
|
|
)) |
|
|
|
if err != nil { |
|
|
|