From 708bf4ff072c2ed32afaa088869c0706b7177b58 Mon Sep 17 00:00:00 2001 From: Juan Leni Date: Wed, 3 Apr 2019 14:40:58 +0200 Subject: [PATCH] check during initialization --- privval/signer_client.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/privval/signer_client.go b/privval/signer_client.go index f52366d08..bc032bb7a 100644 --- a/privval/signer_client.go +++ b/privval/signer_client.go @@ -21,6 +21,10 @@ var _ types.PrivValidator = (*SignerClient)(nil) // NewSignerClient returns an instance of SignerClient. func NewSignerClient(endpoint *SignerListenerEndpoint) (*SignerClient, error) { + if endpoint == nil { + return nil, fmt.Errorf("endpoint cannot be nil") + } + if !endpoint.IsRunning() { if err := endpoint.Start(); err != nil { return nil, errors.Wrap(err, "failed to start private validator") @@ -42,9 +46,6 @@ func (sc *SignerClient) IsConnected() bool { // WaitForConnection waits maxWait for a connection or returns a timeout error func (sc *SignerClient) WaitForConnection(maxWait time.Duration) error { - if sc.endpoint == nil { - return fmt.Errorf("endpoint has not been defined") - } return sc.endpoint.WaitForConnection(maxWait) }