From e2736c8474c82101116786f71499071e77779ca5 Mon Sep 17 00:00:00 2001 From: Matthias <5011972+fasmat@users.noreply.github.com> Date: Tue, 12 Sep 2023 15:21:00 +0000 Subject: [PATCH] Add timeout to powparams request --- activation/nipost.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/activation/nipost.go b/activation/nipost.go index 07e554d34f..cf1a125286 100644 --- a/activation/nipost.go +++ b/activation/nipost.go @@ -330,7 +330,9 @@ func (nb *NIPostBuilder) submitPoetChallenge(ctx context.Context, client PoetPro logger := nb.log.WithContext(ctx).WithFields(log.String("poet_id", hex.EncodeToString(poetServiceID.ServiceID))) logger.Debug("querying for poet pow parameters") - powParams, err := client.PowParams(ctx) + powCtx, cancel := context.WithTimeout(ctx, nb.poetCfg.RequestTimeout) + defer cancel() + powParams, err := client.PowParams(powCtx) if err != nil { return nil, &PoetSvcUnstableError{msg: "failed to get PoW params", source: err} } @@ -345,9 +347,9 @@ func (nb *NIPostBuilder) submitPoetChallenge(ctx context.Context, client PoetPro logger.Debug("submitting challenge to poet proving service") - ctx, cancel := context.WithTimeout(ctx, nb.poetCfg.RequestTimeout) + submitCtx, cancel := context.WithTimeout(ctx, nb.poetCfg.RequestTimeout) defer cancel() - round, err := client.Submit(ctx, prefix, challenge, signature, nodeID, PoetPoW{ + round, err := client.Submit(submitCtx, prefix, challenge, signature, nodeID, PoetPoW{ Nonce: nonce, Params: *powParams, })