[#1461] cli: Add context to GetCurrentEpoch helper

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-06-17 10:36:23 +03:00 committed by fyrchik
parent 51afcc1182
commit b1e54dec9f
3 changed files with 13 additions and 7 deletions

View file

@ -1,8 +1,10 @@
package object
import (
"context"
"fmt"
"strconv"
"time"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/client"
@ -52,9 +54,12 @@ var objectLockCmd = &cobra.Command{
common.ExitOnErr(cmd, "Parsing expiration epoch: %w", err)
if relative {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()
endpoint, _ := cmd.Flags().GetString(commonflags.RPC)
currEpoch, err := internalclient.GetCurrentEpoch(endpoint)
currEpoch, err := internalclient.GetCurrentEpoch(ctx, endpoint)
common.ExitOnErr(cmd, "Request current epoch: %w", err)
exp += currEpoch