diff --git a/blocks/blockstoreutil/remove.go b/blocks/blockstoreutil/remove.go index f2395055a1e..f4d93ea0de4 100644 --- a/blocks/blockstoreutil/remove.go +++ b/blocks/blockstoreutil/remove.go @@ -2,6 +2,7 @@ package blockstoreutil import ( + "context" "fmt" "io" @@ -33,7 +34,7 @@ type RmBlocksOpts struct { // It returns a channel where objects of type RemovedBlock are placed, when // not using the Quiet option. Block removal is asynchronous and will // skip any pinned blocks. -func RmBlocks(blocks bs.GCBlockstore, pins pin.Pinner, cids []cid.Cid, opts RmBlocksOpts) (<-chan interface{}, error) { +func RmBlocks(ctx context.Context, blocks bs.GCBlockstore, pins pin.Pinner, cids []cid.Cid, opts RmBlocksOpts) (<-chan interface{}, error) { // make the channel large enough to hold any result to avoid // blocking while holding the GCLock out := make(chan interface{}, len(cids)) @@ -43,7 +44,7 @@ func RmBlocks(blocks bs.GCBlockstore, pins pin.Pinner, cids []cid.Cid, opts RmBl unlocker := blocks.GCLock() defer unlocker.Unlock() - stillOkay := FilterPinned(pins, out, cids) + stillOkay := FilterPinned(ctx, pins, out, cids) for _, c := range stillOkay { // Kept for backwards compatibility. We may want to @@ -74,9 +75,9 @@ func RmBlocks(blocks bs.GCBlockstore, pins pin.Pinner, cids []cid.Cid, opts RmBl // out channel, with an error which indicates that the Cid is pinned. // This function is used in RmBlocks to filter out any blocks which are not // to be removed (because they are pinned). -func FilterPinned(pins pin.Pinner, out chan<- interface{}, cids []cid.Cid) []cid.Cid { +func FilterPinned(ctx context.Context, pins pin.Pinner, out chan<- interface{}, cids []cid.Cid) []cid.Cid { stillOkay := make([]cid.Cid, 0, len(cids)) - res, err := pins.CheckIfPinned(cids...) + res, err := pins.CheckIfPinned(ctx, cids...) if err != nil { out <- &RemovedBlock{Error: fmt.Sprintf("pin check failed: %s", err)} return nil diff --git a/core/commands/pin.go b/core/commands/pin.go index b77ac7433f5..c6e5ca6b547 100644 --- a/core/commands/pin.go +++ b/core/commands/pin.go @@ -446,7 +446,7 @@ func pinLsKeys(req *cmds.Request, typeStr string, n *core.IpfsNode, api coreifac return err } - pinType, pinned, err := n.Pinning.IsPinnedWithType(c.Cid(), mode) + pinType, pinned, err := n.Pinning.IsPinnedWithType(req.Context, c.Cid(), mode) if err != nil { return err } @@ -501,19 +501,31 @@ func pinLsAll(req *cmds.Request, typeStr string, n *core.IpfsNode, emit func(val } if typeStr == "direct" || typeStr == "all" { - err := AddToResultKeys(n.Pinning.DirectKeys(), "direct") + dkeys, err := n.Pinning.DirectKeys(req.Context) + if err != nil { + return err + } + err = AddToResultKeys(dkeys, "direct") if err != nil { return err } } if typeStr == "recursive" || typeStr == "all" { - err := AddToResultKeys(n.Pinning.RecursiveKeys(), "recursive") + rkeys, err := n.Pinning.RecursiveKeys(req.Context) + if err != nil { + return err + } + err = AddToResultKeys(rkeys, "recursive") if err != nil { return err } } if typeStr == "indirect" || typeStr == "all" { - for _, k := range n.Pinning.RecursiveKeys() { + rkeys, err := n.Pinning.RecursiveKeys(req.Context) + if err != nil { + return err + } + for _, k := range rkeys { var visitErr error err := dag.Walk(req.Context, dag.GetLinksWithDAG(n.DAG), k, func(c cid.Cid) bool { r := keys.Visit(c) @@ -642,8 +654,10 @@ var verifyPinCmd = &cmds.Command{ explain: !quiet, includeOk: verbose, } - out := pinVerify(req.Context, n, opts, enc) - + out, err := pinVerify(req.Context, n, opts, enc) + if err != nil { + return err + } return res.Emit(out) }, Type: PinVerifyRes{}, @@ -685,13 +699,16 @@ type pinVerifyOpts struct { includeOk bool } -func pinVerify(ctx context.Context, n *core.IpfsNode, opts pinVerifyOpts, enc cidenc.Encoder) <-chan interface{} { +func pinVerify(ctx context.Context, n *core.IpfsNode, opts pinVerifyOpts, enc cidenc.Encoder) (<-chan interface{}, error) { visited := make(map[cid.Cid]PinStatus) bs := n.Blocks.Blockstore() DAG := dag.NewDAGService(bserv.New(bs, offline.Exchange(bs))) getLinks := dag.GetLinksWithDAG(DAG) - recPins := n.Pinning.RecursiveKeys() + recPins, err := n.Pinning.RecursiveKeys(ctx) + if err != nil { + return nil, err + } var checkPin func(root cid.Cid) PinStatus checkPin = func(root cid.Cid) PinStatus { @@ -747,7 +764,7 @@ func pinVerify(ctx context.Context, n *core.IpfsNode, opts pinVerifyOpts, enc ci } }() - return out + return out, nil } // Format formats PinVerifyRes diff --git a/core/coreapi/block.go b/core/coreapi/block.go index 2a371b904f0..f9f43bfc6f2 100644 --- a/core/coreapi/block.go +++ b/core/coreapi/block.go @@ -56,7 +56,7 @@ func (api *BlockAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.Bloc if settings.Pin { api.pinning.PinWithMode(b.Cid(), pin.Recursive) - if err := api.pinning.Flush(); err != nil { + if err := api.pinning.Flush(ctx); err != nil { return nil, err } } @@ -91,7 +91,7 @@ func (api *BlockAPI) Rm(ctx context.Context, p path.Path, opts ...caopts.BlockRm cids := []cid.Cid{rp.Cid()} o := util.RmBlocksOpts{Force: settings.Force} - out, err := util.RmBlocks(api.blockstore, api.pinning, cids, o) + out, err := util.RmBlocks(ctx, api.blockstore, api.pinning, cids, o) if err != nil { return err } diff --git a/core/coreapi/dag.go b/core/coreapi/dag.go index 9e72d067334..d2ec4505cce 100644 --- a/core/coreapi/dag.go +++ b/core/coreapi/dag.go @@ -26,7 +26,7 @@ func (adder *pinningAdder) Add(ctx context.Context, nd ipld.Node) error { adder.pinning.PinWithMode(nd.Cid(), pin.Recursive) - return adder.pinning.Flush() + return adder.pinning.Flush(ctx) } func (adder *pinningAdder) AddMany(ctx context.Context, nds []ipld.Node) error { @@ -45,7 +45,7 @@ func (adder *pinningAdder) AddMany(ctx context.Context, nds []ipld.Node) error { } } - return adder.pinning.Flush() + return adder.pinning.Flush(ctx) } func (api *dagAPI) Pinning() ipld.NodeAdder { diff --git a/core/coreapi/object.go b/core/coreapi/object.go index 2c1678d9d91..fd1e824cc59 100644 --- a/core/coreapi/object.go +++ b/core/coreapi/object.go @@ -119,7 +119,7 @@ func (api *ObjectAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.Obj if options.Pin { api.pinning.PinWithMode(dagnode.Cid(), pin.Recursive) - err = api.pinning.Flush() + err = api.pinning.Flush(ctx) if err != nil { return nil, err } diff --git a/core/coreapi/pin.go b/core/coreapi/pin.go index 15951687b83..2447ec8a0ed 100644 --- a/core/coreapi/pin.go +++ b/core/coreapi/pin.go @@ -37,7 +37,7 @@ func (api *PinAPI) Add(ctx context.Context, p path.Path, opts ...caopts.PinAddOp return err } - return api.pinning.Flush() + return api.pinning.Flush(ctx) } func (api *PinAPI) Ls(ctx context.Context, opts ...caopts.PinLsOption) ([]coreiface.Pin, error) { @@ -75,7 +75,7 @@ func (api *PinAPI) Rm(ctx context.Context, p path.Path, opts ...caopts.PinRmOpti return err } - return api.pinning.Flush() + return api.pinning.Flush(ctx) } func (api *PinAPI) Update(ctx context.Context, from path.Path, to path.Path, opts ...caopts.PinUpdateOption) error { @@ -101,7 +101,7 @@ func (api *PinAPI) Update(ctx context.Context, from path.Path, to path.Path, opt return err } - return api.pinning.Flush() + return api.pinning.Flush(ctx) } type pinStatus struct { @@ -137,7 +137,10 @@ func (api *PinAPI) Verify(ctx context.Context) (<-chan coreiface.PinStatus, erro bs := api.blockstore DAG := merkledag.NewDAGService(bserv.New(bs, offline.Exchange(bs))) getLinks := merkledag.GetLinksWithDAG(DAG) - recPins := api.pinning.RecursiveKeys() + recPins, err := api.pinning.RecursiveKeys(ctx) + if err != nil { + return nil, err + } var checkPin func(root cid.Cid) *pinStatus checkPin = func(root cid.Cid) *pinStatus { @@ -204,11 +207,19 @@ func (api *PinAPI) pinLsAll(typeStr string, ctx context.Context) ([]coreiface.Pi } if typeStr == "direct" || typeStr == "all" { - AddToResultKeys(api.pinning.DirectKeys(), "direct") + dkeys, err := api.pinning.DirectKeys(ctx) + if err != nil { + return nil, err + } + AddToResultKeys(dkeys, "direct") } if typeStr == "indirect" || typeStr == "all" { set := cid.NewSet() - for _, k := range api.pinning.RecursiveKeys() { + rkeys, err := api.pinning.RecursiveKeys(ctx) + if err != nil { + return nil, err + } + for _, k := range rkeys { err := merkledag.Walk( ctx, merkledag.GetLinksWithDAG(api.dag), k, set.Visit, @@ -221,7 +232,11 @@ func (api *PinAPI) pinLsAll(typeStr string, ctx context.Context) ([]coreiface.Pi AddToResultKeys(set.Keys(), "indirect") } if typeStr == "recursive" || typeStr == "all" { - AddToResultKeys(api.pinning.RecursiveKeys(), "recursive") + rkeys, err := api.pinning.RecursiveKeys(ctx) + if err != nil { + return nil, err + } + AddToResultKeys(rkeys, "recursive") } out := make([]coreiface.Pin, 0, len(keys)) diff --git a/core/coreunix/add.go b/core/coreunix/add.go index 1a348855b66..2bbec78647a 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -176,7 +176,7 @@ func (adder *Adder) PinRoot(root ipld.Node) error { } adder.pinning.PinWithMode(rnk, pin.Recursive) - return adder.pinning.Flush() + return adder.pinning.Flush(adder.ctx) } func (adder *Adder) outputDirs(path string, fsn mfs.FSNode) error { diff --git a/fuse/ipns/common.go b/fuse/ipns/common.go index 182236aabf3..48129a92e98 100644 --- a/fuse/ipns/common.go +++ b/fuse/ipns/common.go @@ -23,7 +23,7 @@ func InitializeKeyspace(n *core.IpfsNode, key ci.PrivKey) error { return err } - err = n.Pinning.Flush() + err = n.Pinning.Flush(ctx) if err != nil { return err } diff --git a/go.mod b/go.mod index 8dcf9360026..c7ba2ed6d76 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( github.com/ipfs/go-ipfs-exchange-offline v0.0.1 github.com/ipfs/go-ipfs-files v0.0.4 github.com/ipfs/go-ipfs-posinfo v0.0.1 - github.com/ipfs/go-ipfs-provider v0.2.2 + github.com/ipfs/go-ipfs-provider v0.3.0 github.com/ipfs/go-ipfs-routing v0.1.0 github.com/ipfs/go-ipfs-util v0.0.1 github.com/ipfs/go-ipld-cbor v0.0.3 diff --git a/go.sum b/go.sum index fee0ef59a8e..9620ee35623 100644 --- a/go.sum +++ b/go.sum @@ -213,8 +213,8 @@ github.com/ipfs/go-ipfs-posinfo v0.0.1 h1:Esoxj+1JgSjX0+ylc0hUmJCOv6V2vFoZiETLR6 github.com/ipfs/go-ipfs-posinfo v0.0.1/go.mod h1:SwyeVP+jCwiDu0C313l/8jg6ZxM0qqtlt2a0vILTc1A= github.com/ipfs/go-ipfs-pq v0.0.1 h1:zgUotX8dcAB/w/HidJh1zzc1yFq6Vm8J7T2F4itj/RU= github.com/ipfs/go-ipfs-pq v0.0.1/go.mod h1:LWIqQpqfRG3fNc5XsnIhz/wQ2XXGyugQwls7BgUmUfY= -github.com/ipfs/go-ipfs-provider v0.2.2 h1:/YcpqQtg27JhgOig9jbGxhDXmSKOZ0pvqrCW1+f8Q+U= -github.com/ipfs/go-ipfs-provider v0.2.2/go.mod h1:rcQBVqfblDQRk5LaCtf2uxuKxMJxvKmF5pLS0pO4au4= +github.com/ipfs/go-ipfs-provider v0.3.0 h1:W3AO8YQVPK/9NFu1HRJxuMZftw6K+rWv1j3y5K5e06A= +github.com/ipfs/go-ipfs-provider v0.3.0/go.mod h1:rcQBVqfblDQRk5LaCtf2uxuKxMJxvKmF5pLS0pO4au4= github.com/ipfs/go-ipfs-routing v0.0.1/go.mod h1:k76lf20iKFxQTjcJokbPM9iBXVXVZhcOwc360N4nuKs= github.com/ipfs/go-ipfs-routing v0.1.0 h1:gAJTT1cEeeLj6/DlLX6t+NxD9fQe2ymTO6qWRDI/HQQ= github.com/ipfs/go-ipfs-routing v0.1.0/go.mod h1:hYoUkJLyAUKhF58tysKpids8RNDPO42BVMgK5dNsoqY= diff --git a/namesys/publisher.go b/namesys/publisher.go index c06deb795ae..17c4e1b3fc2 100644 --- a/namesys/publisher.go +++ b/namesys/publisher.go @@ -298,7 +298,7 @@ func InitializeKeyspace(ctx context.Context, pub Publisher, pins pin.Pinner, key return err } - err = pins.Flush() + err = pins.Flush(ctx) if err != nil { return err } diff --git a/pin/gc/gc.go b/pin/gc/gc.go index e03072770ec..a8309aeac47 100644 --- a/pin/gc/gc.go +++ b/pin/gc/gc.go @@ -201,7 +201,11 @@ func ColoredSet(ctx context.Context, pn pin.Pinner, ng ipld.NodeGetter, bestEffo } return links, nil } - err := Descendants(ctx, getLinks, gcs, pn.RecursiveKeys()) + rkeys, err := pn.RecursiveKeys(ctx) + if err != nil { + return nil, err + } + err = Descendants(ctx, getLinks, gcs, rkeys) if err != nil { errors = true select { @@ -233,11 +237,19 @@ func ColoredSet(ctx context.Context, pn pin.Pinner, ng ipld.NodeGetter, bestEffo } } - for _, k := range pn.DirectKeys() { + dkeys, err := pn.DirectKeys(ctx) + if err != nil { + return nil, err + } + for _, k := range dkeys { gcs.Add(k) } - err = Descendants(ctx, getLinks, gcs, pn.InternalPins()) + ikeys, err := pn.InternalPins(ctx) + if err != nil { + return nil, err + } + err = Descendants(ctx, getLinks, gcs, ikeys) if err != nil { errors = true select { diff --git a/pin/pin.go b/pin/pin.go index 63fa663c16d..15b2396b552 100644 --- a/pin/pin.go +++ b/pin/pin.go @@ -105,11 +105,11 @@ func StringToMode(s string) (Mode, bool) { type Pinner interface { // IsPinned returns whether or not the given cid is pinned // and an explanation of why its pinned - IsPinned(cid.Cid) (string, bool, error) + IsPinned(ctx context.Context, c cid.Cid) (string, bool, error) // IsPinnedWithType returns whether or not the given cid is pinned with the // given pin type, as well as returning the type of pin its pinned with. - IsPinnedWithType(cid.Cid, Mode) (string, bool, error) + IsPinnedWithType(ctx context.Context, c cid.Cid, mode Mode) (string, bool, error) // Pin the given node, optionally recursively. Pin(ctx context.Context, node ipld.Node, recursive bool) error @@ -125,7 +125,7 @@ type Pinner interface { // Check if a set of keys are pinned, more efficient than // calling IsPinned for each key - CheckIfPinned(cids ...cid.Cid) ([]Pinned, error) + CheckIfPinned(ctx context.Context, cids ...cid.Cid) ([]Pinned, error) // PinWithMode is for manually editing the pin structure. Use with // care! If used improperly, garbage collection may not be @@ -138,17 +138,17 @@ type Pinner interface { RemovePinWithMode(cid.Cid, Mode) // Flush writes the pin state to the backing datastore - Flush() error + Flush(ctx context.Context) error // DirectKeys returns all directly pinned cids - DirectKeys() []cid.Cid + DirectKeys(ctx context.Context) ([]cid.Cid, error) // DirectKeys returns all recursively pinned cids - RecursiveKeys() []cid.Cid + RecursiveKeys(ctx context.Context) ([]cid.Cid, error) // InternalPins returns all cids kept pinned for the internal state of the // pinner - InternalPins() []cid.Cid + InternalPins(ctx context.Context) ([]cid.Cid, error) } // Pinned represents CID which has been pinned with a pinning strategy. @@ -211,8 +211,6 @@ func NewPinner(dstore ds.Datastore, serv, internal ipld.DAGService) Pinner { // Pin the given node, optionally recursive func (p *pinner) Pin(ctx context.Context, node ipld.Node, recurse bool) error { - p.lock.Lock() - defer p.lock.Unlock() err := p.dserv.Add(ctx, node) if err != nil { return err @@ -220,13 +218,16 @@ func (p *pinner) Pin(ctx context.Context, node ipld.Node, recurse bool) error { c := node.Cid() + p.lock.Lock() + defer p.lock.Unlock() + if recurse { if p.recursePin.Has(c) { return nil } p.lock.Unlock() - // fetch entire graph + // temporary unlock to fetch the entire graph err := mdag.FetchGraph(ctx, c, p.dserv) p.lock.Lock() if err != nil { @@ -243,13 +244,6 @@ func (p *pinner) Pin(ctx context.Context, node ipld.Node, recurse bool) error { p.recursePin.Add(c) } else { - p.lock.Unlock() - _, err := p.dserv.Get(ctx, c) - p.lock.Lock() - if err != nil { - return err - } - if p.recursePin.Has(c) { return fmt.Errorf("%s already pinned recursively", c.String()) } @@ -286,23 +280,23 @@ func (p *pinner) isInternalPin(c cid.Cid) bool { // IsPinned returns whether or not the given key is pinned // and an explanation of why its pinned -func (p *pinner) IsPinned(c cid.Cid) (string, bool, error) { +func (p *pinner) IsPinned(ctx context.Context, c cid.Cid) (string, bool, error) { p.lock.RLock() defer p.lock.RUnlock() - return p.isPinnedWithType(c, Any) + return p.isPinnedWithType(ctx, c, Any) } // IsPinnedWithType returns whether or not the given cid is pinned with the // given pin type, as well as returning the type of pin its pinned with. -func (p *pinner) IsPinnedWithType(c cid.Cid, mode Mode) (string, bool, error) { +func (p *pinner) IsPinnedWithType(ctx context.Context, c cid.Cid, mode Mode) (string, bool, error) { p.lock.RLock() defer p.lock.RUnlock() - return p.isPinnedWithType(c, mode) + return p.isPinnedWithType(ctx, c, mode) } // isPinnedWithType is the implementation of IsPinnedWithType that does not lock. // intended for use by other pinned methods that already take locks -func (p *pinner) isPinnedWithType(c cid.Cid, mode Mode) (string, bool, error) { +func (p *pinner) isPinnedWithType(ctx context.Context, c cid.Cid, mode Mode) (string, bool, error) { switch mode { case Any, Direct, Indirect, Recursive, Internal: default: @@ -334,7 +328,7 @@ func (p *pinner) isPinnedWithType(c cid.Cid, mode Mode) (string, bool, error) { // Default is Indirect visitedSet := cid.NewSet() for _, rc := range p.recursePin.Keys() { - has, err := hasChild(p.dserv, rc, c, visitedSet.Visit) + has, err := hasChild(ctx, p.dserv, rc, c, visitedSet.Visit) if err != nil { return "", false, err } @@ -347,7 +341,7 @@ func (p *pinner) isPinnedWithType(c cid.Cid, mode Mode) (string, bool, error) { // CheckIfPinned Checks if a set of keys are pinned, more efficient than // calling IsPinned for each key, returns the pinned status of cid(s) -func (p *pinner) CheckIfPinned(cids ...cid.Cid) ([]Pinned, error) { +func (p *pinner) CheckIfPinned(ctx context.Context, cids ...cid.Cid) ([]Pinned, error) { p.lock.RLock() defer p.lock.RUnlock() pinned := make([]Pinned, 0, len(cids)) @@ -369,7 +363,7 @@ func (p *pinner) CheckIfPinned(cids ...cid.Cid) ([]Pinned, error) { // Now walk all recursive pins to check for indirect pins var checkChildren func(cid.Cid, cid.Cid) error checkChildren = func(rk, parentKey cid.Cid) error { - links, err := ipld.GetLinks(context.TODO(), p.dserv, parentKey) + links, err := ipld.GetLinks(ctx, p.dserv, parentKey) if err != nil { return err } @@ -494,19 +488,19 @@ func LoadPinner(d ds.Datastore, dserv, internal ipld.DAGService) (Pinner, error) } // DirectKeys returns a slice containing the directly pinned keys -func (p *pinner) DirectKeys() []cid.Cid { +func (p *pinner) DirectKeys(ctx context.Context) ([]cid.Cid, error) { p.lock.RLock() defer p.lock.RUnlock() - return p.directPin.Keys() + return p.directPin.Keys(), nil } // RecursiveKeys returns a slice containing the recursively pinned keys -func (p *pinner) RecursiveKeys() []cid.Cid { +func (p *pinner) RecursiveKeys(ctx context.Context) ([]cid.Cid, error) { p.lock.RLock() defer p.lock.RUnlock() - return p.recursePin.Keys() + return p.recursePin.Keys(), nil } // Update updates a recursive pin from one cid to another @@ -541,12 +535,10 @@ func (p *pinner) Update(ctx context.Context, from, to cid.Cid, unpin bool) error } // Flush encodes and writes pinner keysets to the datastore -func (p *pinner) Flush() error { +func (p *pinner) Flush(ctx context.Context) error { p.lock.Lock() defer p.lock.Unlock() - ctx := context.TODO() - internalset := cid.NewSet() recordInternal := internalset.Add @@ -594,12 +586,12 @@ func (p *pinner) Flush() error { // InternalPins returns all cids kept pinned for the internal state of the // pinner -func (p *pinner) InternalPins() []cid.Cid { +func (p *pinner) InternalPins(ctx context.Context) ([]cid.Cid, error) { p.lock.Lock() defer p.lock.Unlock() var out []cid.Cid out = append(out, p.internalPin.Keys()...) - return out + return out, nil } // PinWithMode allows the user to have fine grained control over pin @@ -617,8 +609,8 @@ func (p *pinner) PinWithMode(c cid.Cid, mode Mode) { // hasChild recursively looks for a Cid among the children of a root Cid. // The visit function can be used to shortcut already-visited branches. -func hasChild(ng ipld.NodeGetter, root cid.Cid, child cid.Cid, visit func(cid.Cid) bool) (bool, error) { - links, err := ipld.GetLinks(context.TODO(), ng, root) +func hasChild(ctx context.Context, ng ipld.NodeGetter, root cid.Cid, child cid.Cid, visit func(cid.Cid) bool) (bool, error) { + links, err := ipld.GetLinks(ctx, ng, root) if err != nil { return false, err } @@ -628,7 +620,7 @@ func hasChild(ng ipld.NodeGetter, root cid.Cid, child cid.Cid, visit func(cid.Ci return true, nil } if visit(c) { - has, err := hasChild(ng, c, child, visit) + has, err := hasChild(ctx, ng, c, child, visit) if err != nil { return false, err } diff --git a/pin/pin_test.go b/pin/pin_test.go index 27e4c71dee5..e477ac07fe0 100644 --- a/pin/pin_test.go +++ b/pin/pin_test.go @@ -31,7 +31,7 @@ func randNode() (*mdag.ProtoNode, cid.Cid) { } func assertPinned(t *testing.T, p Pinner, c cid.Cid, failmsg string) { - _, pinned, err := p.IsPinned(c) + _, pinned, err := p.IsPinned(context.Background(), c) if err != nil { t.Fatal(err) } @@ -42,7 +42,7 @@ func assertPinned(t *testing.T, p Pinner, c cid.Cid, failmsg string) { } func assertUnpinned(t *testing.T, p Pinner, c cid.Cid, failmsg string) { - _, pinned, err := p.IsPinned(c) + _, pinned, err := p.IsPinned(context.Background(), c) if err != nil { t.Fatal(err) } @@ -146,7 +146,7 @@ func TestPinnerBasic(t *testing.T) { t.Fatal(err) } - err = p.Flush() + err = p.Flush(ctx) if err != nil { t.Fatal(err) } @@ -327,7 +327,7 @@ func TestFlush(t *testing.T) { _, k := randNode() p.PinWithMode(k, Recursive) - if err := p.Flush(); err != nil { + if err := p.Flush(context.Background()); err != nil { t.Fatal(err) } assertPinned(t, p, k, "expected key to still be pinned")