Skip to content

Commit

Permalink
Add timeout to powparams request
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Sep 12, 2023
1 parent 4eed88f commit e2736c8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions activation/nipost.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand All @@ -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,
})
Expand Down

0 comments on commit e2736c8

Please sign in to comment.