From 289ea3d33fd397a610384fee5024d1c8ecbf18ff Mon Sep 17 00:00:00 2001 From: vyzo Date: Mon, 13 Dec 2021 14:35:24 +0200 Subject: [PATCH] plumb contexts in lotus-shed --- cmd/lotus-shed/datastore.go | 4 ++-- cmd/lotus-shed/export.go | 4 ++-- cmd/lotus-shed/import-car.go | 4 ++-- cmd/lotus-shed/market.go | 7 ++++--- cmd/lotus-shed/pruning.go | 2 +- cmd/lotus-shed/splitstore.go | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cmd/lotus-shed/datastore.go b/cmd/lotus-shed/datastore.go index c3a9e572c..ff740a772 100644 --- a/cmd/lotus-shed/datastore.go +++ b/cmd/lotus-shed/datastore.go @@ -83,7 +83,7 @@ var datastoreListCmd = &cli.Command{ genc := cctx.String("get-enc") - q, err := ds.Query(dsq.Query{ + q, err := ds.Query(context.Background(), dsq.Query{ Prefix: datastore.NewKey(cctx.Args().Get(1)).String(), KeysOnly: genc == "", }) @@ -147,7 +147,7 @@ var datastoreGetCmd = &cli.Command{ return err } - val, err := ds.Get(datastore.NewKey(cctx.Args().Get(1))) + val, err := ds.Get(context.Background(), datastore.NewKey(cctx.Args().Get(1))) if err != nil { return xerrors.Errorf("get: %w", err) } diff --git a/cmd/lotus-shed/export.go b/cmd/lotus-shed/export.go index e711ba2bb..3851e4922 100644 --- a/cmd/lotus-shed/export.go +++ b/cmd/lotus-shed/export.go @@ -93,7 +93,7 @@ var exportChainCmd = &cli.Command{ cs := store.NewChainStore(bs, bs, mds, nil, nil) defer cs.Close() //nolint:errcheck - if err := cs.Load(); err != nil { + if err := cs.Load(context.Background()); err != nil { return err } @@ -110,7 +110,7 @@ var exportChainCmd = &cli.Command{ tsk := types.NewTipSetKey(cids...) - selts, err := cs.LoadTipSet(tsk) + selts, err := cs.LoadTipSet(context.Background(), tsk) if err != nil { return xerrors.Errorf("loading tipset: %w", err) } diff --git a/cmd/lotus-shed/import-car.go b/cmd/lotus-shed/import-car.go index 4e465029f..973e7b31b 100644 --- a/cmd/lotus-shed/import-car.go +++ b/cmd/lotus-shed/import-car.go @@ -82,7 +82,7 @@ var importCarCmd = &cli.Command{ return err case nil: fmt.Printf("\r%s", blk.Cid()) - if err := bs.Put(blk); err != nil { + if err := bs.Put(context.Background(), blk); err != nil { if err := f.Close(); err != nil { return err } @@ -146,7 +146,7 @@ var importObjectCmd = &cli.Command{ return err } - if err := bs.Put(blk); err != nil { + if err := bs.Put(context.Background(), blk); err != nil { return err } diff --git a/cmd/lotus-shed/market.go b/cmd/lotus-shed/market.go index 8221e53eb..aaef4690e 100644 --- a/cmd/lotus-shed/market.go +++ b/cmd/lotus-shed/market.go @@ -1,6 +1,7 @@ package main import ( + "context" "fmt" "os" "path" @@ -198,7 +199,7 @@ var marketExportDatastoreCmd = &cli.Command{ } // Write the backup to the file - if err := bds.Backup(out); err != nil { + if err := bds.Backup(context.Background(), out); err != nil { if cerr := out.Close(); cerr != nil { log.Errorw("error closing backup file while handling backup error", "closeErr", cerr, "backupErr", err) } @@ -215,7 +216,7 @@ var marketExportDatastoreCmd = &cli.Command{ } func exportPrefix(prefix string, ds datastore.Batching, backupDs datastore.Batching) error { - q, err := ds.Query(dsq.Query{ + q, err := ds.Query(context.Background(), dsq.Query{ Prefix: prefix, }) if err != nil { @@ -225,7 +226,7 @@ func exportPrefix(prefix string, ds datastore.Batching, backupDs datastore.Batch for res := range q.Next() { fmt.Println("Exporting key " + res.Key) - err := backupDs.Put(datastore.NewKey(res.Key), res.Value) + err := backupDs.Put(context.Background(), datastore.NewKey(res.Key), res.Value) if err != nil { return xerrors.Errorf("putting %s to backup datastore: %w", res.Key, err) } diff --git a/cmd/lotus-shed/pruning.go b/cmd/lotus-shed/pruning.go index 186a3191a..164ff197a 100644 --- a/cmd/lotus-shed/pruning.go +++ b/cmd/lotus-shed/pruning.go @@ -171,7 +171,7 @@ var stateTreePruneCmd = &cli.Command{ cs := store.NewChainStore(bs, bs, mds, filcns.Weight, nil) defer cs.Close() //nolint:errcheck - if err := cs.Load(); err != nil { + if err := cs.Load(context.Background()); err != nil { return fmt.Errorf("loading chainstore: %w", err) } diff --git a/cmd/lotus-shed/splitstore.go b/cmd/lotus-shed/splitstore.go index 4f668888e..58563955f 100644 --- a/cmd/lotus-shed/splitstore.go +++ b/cmd/lotus-shed/splitstore.go @@ -331,7 +331,7 @@ func deleteSplitstoreKeys(lr repo.LockedRepo) error { } var keys []datastore.Key - res, err := ds.Query(query.Query{Prefix: "/splitstore"}) + res, err := ds.Query(context.Background(), query.Query{Prefix: "/splitstore"}) if err != nil { return xerrors.Errorf("error querying datastore for splitstore keys: %w", err) } @@ -346,7 +346,7 @@ func deleteSplitstoreKeys(lr repo.LockedRepo) error { for _, k := range keys { fmt.Printf("deleting %s from datastore...\n", k) - err = ds.Delete(k) + err = ds.Delete(context.Background(), k) if err != nil { return xerrors.Errorf("error deleting key %s from datastore: %w", k, err) }