state/privval: no GetPubKey retry beyond the proposal/voting window (#6578)

Closes #5142
This commit is contained in:
JayT106
2021-06-28 13:50:25 +00:00
committed by GitHub
parent c5cc3c8d3f
commit 11a71c228c
4 changed files with 49 additions and 4 deletions
+8 -1
View File
@@ -50,6 +50,8 @@ func (sc *RetrySignerClient) GetPubKey(ctx context.Context) (crypto.PubKey, erro
pk crypto.PubKey
err error
)
t := time.NewTimer(sc.timeout)
for i := 0; i < sc.retries || sc.retries == 0; i++ {
pk, err = sc.next.GetPubKey(ctx)
if err == nil {
@@ -59,7 +61,12 @@ func (sc *RetrySignerClient) GetPubKey(ctx context.Context) (crypto.PubKey, erro
if _, ok := err.(*RemoteSignerError); ok {
return nil, err
}
time.Sleep(sc.timeout)
select {
case <-ctx.Done():
return nil, ctx.Err()
case <-t.C:
t.Reset(sc.timeout)
}
}
return nil, fmt.Errorf("exhausted all attempts to get pubkey: %w", err)
}