diff --git a/blocks/blockstoreutil/remove.go b/blocks/blockstoreutil/remove.go index 52a18fd0f3a..9890365a329 100644 --- a/blocks/blockstoreutil/remove.go +++ b/blocks/blockstoreutil/remove.go @@ -48,7 +48,7 @@ func RmBlocks(ctx context.Context, blocks bs.GCBlockstore, pins pin.Pinner, cids for _, c := range stillOkay { // Kept for backwards compatibility. We may want to // remove this sometime in the future. - has, err := blocks.Has(c) + has, err := blocks.Has(ctx, c) if err != nil { out <- &RemovedBlock{Hash: c.String(), Error: err.Error()} continue @@ -58,7 +58,7 @@ func RmBlocks(ctx context.Context, blocks bs.GCBlockstore, pins pin.Pinner, cids continue } - err = blocks.DeleteBlock(c) + err = blocks.DeleteBlock(ctx, c) if err != nil { out <- &RemovedBlock{Hash: c.String(), Error: err.Error()} } else if !opts.Quiet { diff --git a/core/commands/dag/dag.go b/core/commands/dag/dag.go index 85588be2f14..8a0aa4467cc 100644 --- a/core/commands/dag/dag.go +++ b/core/commands/dag/dag.go @@ -380,7 +380,7 @@ Maximum supported CAR version: 1 ret := RootMeta{Cid: c} - if block, err := node.Blockstore.Get(c); err != nil { + if block, err := node.Blockstore.Get(req.Context, c); err != nil { ret.PinErrorMsg = err.Error() } else if nd, err := ipld.Decode(block); err != nil { ret.PinErrorMsg = err.Error() diff --git a/core/commands/dht.go b/core/commands/dht.go index aeaa7712b80..a41b459c3a9 100644 --- a/core/commands/dht.go +++ b/core/commands/dht.go @@ -262,7 +262,7 @@ var provideRefDhtCmd = &cmds.Command{ return err } - has, err := nd.Blockstore.Has(c) + has, err := nd.Blockstore.Has(req.Context, c) if err != nil { return err } diff --git a/core/commands/filestore.go b/core/commands/filestore.go index c36308bc140..0753fe69a3c 100644 --- a/core/commands/filestore.go +++ b/core/commands/filestore.go @@ -1,6 +1,7 @@ package commands import ( + "context" "fmt" "io" "os" @@ -56,11 +57,11 @@ The output is: } args := req.Arguments if len(args) > 0 { - return listByArgs(res, fs, args) + return listByArgs(req.Context, res, fs, args) } fileOrder, _ := req.Options[fileOrderOptionName].(bool) - next, err := filestore.ListAll(fs, fileOrder) + next, err := filestore.ListAll(req.Context, fs, fileOrder) if err != nil { return err } @@ -133,11 +134,11 @@ For ERROR entries the error will also be printed to stderr. } args := req.Arguments if len(args) > 0 { - return listByArgs(res, fs, args) + return listByArgs(req.Context, res, fs, args) } fileOrder, _ := req.Options[fileOrderOptionName].(bool) - next, err := filestore.VerifyAll(fs, fileOrder) + next, err := filestore.VerifyAll(req.Context, fs, fileOrder) if err != nil { return err } @@ -206,7 +207,7 @@ var dupsFileStore = &cmds.Command{ } for cid := range ch { - have, err := fs.MainBlockstore().Has(cid) + have, err := fs.MainBlockstore().Has(req.Context, cid) if err != nil { return res.Emit(&RefWrapper{Err: err.Error()}) } @@ -235,7 +236,7 @@ func getFilestore(env cmds.Environment) (*core.IpfsNode, *filestore.Filestore, e return n, fs, err } -func listByArgs(res cmds.ResponseEmitter, fs *filestore.Filestore, args []string) error { +func listByArgs(ctx context.Context, res cmds.ResponseEmitter, fs *filestore.Filestore, args []string) error { for _, arg := range args { c, err := cid.Decode(arg) if err != nil { @@ -248,7 +249,7 @@ func listByArgs(res cmds.ResponseEmitter, fs *filestore.Filestore, args []string } continue } - r := filestore.Verify(fs, c) + r := filestore.Verify(ctx, fs, c) if err := res.Emit(r); err != nil { return err } diff --git a/core/commands/repo.go b/core/commands/repo.go index d3de85fdd66..62de00caa15 100644 --- a/core/commands/repo.go +++ b/core/commands/repo.go @@ -238,7 +238,7 @@ func verifyWorkerRun(ctx context.Context, wg *sync.WaitGroup, keys <-chan cid.Ci defer wg.Done() for k := range keys { - _, err := bs.Get(k) + _, err := bs.Get(ctx, k) if err != nil { select { case results <- fmt.Sprintf("block %s was corrupt (%s)", k, err): diff --git a/core/coreapi/block.go b/core/coreapi/block.go index 18d9fb763d6..32d06c90ceb 100644 --- a/core/coreapi/block.go +++ b/core/coreapi/block.go @@ -49,7 +49,7 @@ func (api *BlockAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.Bloc defer api.blockstore.PinLock().Unlock() } - err = api.blocks.AddBlock(b) + err = api.blocks.AddBlock(ctx, b) if err != nil { return nil, err } diff --git a/core/coreapi/dht.go b/core/coreapi/dht.go index 892e7557629..3f10a0ffcf8 100644 --- a/core/coreapi/dht.go +++ b/core/coreapi/dht.go @@ -76,7 +76,7 @@ func (api *DhtAPI) Provide(ctx context.Context, path path.Path, opts ...caopts.D c := rp.Cid() - has, err := api.blockstore.Has(c) + has, err := api.blockstore.Has(ctx, c) if err != nil { return err } diff --git a/core/coreapi/unixfs.go b/core/coreapi/unixfs.go index 53d13a3a497..d506071db68 100644 --- a/core/coreapi/unixfs.go +++ b/core/coreapi/unixfs.go @@ -111,10 +111,10 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options DAGService: dserv, syncFn: func() error { ds := api.repo.Datastore() - if err := ds.Sync(bstore.BlockPrefix); err != nil { + if err := ds.Sync(ctx, bstore.BlockPrefix); err != nil { return err } - return ds.Sync(filestore.FilestorePrefix) + return ds.Sync(ctx, filestore.FilestorePrefix) }, } } diff --git a/core/coreunix/add_test.go b/core/coreunix/add_test.go index 6277e858c2e..f66b35bd688 100644 --- a/core/coreunix/add_test.go +++ b/core/coreunix/add_test.go @@ -327,16 +327,16 @@ type testBlockstore struct { countAtOffsetNonZero int } -func (bs *testBlockstore) Put(block blocks.Block) error { +func (bs *testBlockstore) Put(ctx context.Context, block blocks.Block) error { bs.CheckForPosInfo(block) - return bs.GCBlockstore.Put(block) + return bs.GCBlockstore.Put(ctx, block) } -func (bs *testBlockstore) PutMany(blocks []blocks.Block) error { +func (bs *testBlockstore) PutMany(ctx context.Context, blocks []blocks.Block) error { for _, blk := range blocks { bs.CheckForPosInfo(blk) } - return bs.GCBlockstore.PutMany(blocks) + return bs.GCBlockstore.PutMany(ctx, blocks) } func (bs *testBlockstore) CheckForPosInfo(block blocks.Block) { diff --git a/core/node/core.go b/core/node/core.go index 4c522dbcfc3..28e8ca497c4 100644 --- a/core/node/core.go +++ b/core/node/core.go @@ -40,20 +40,21 @@ func BlockService(lc fx.Lifecycle, bs blockstore.Blockstore, rem exchange.Interf } // Pinning creates new pinner which tells GC which blocks should be kept -func Pinning(bstore blockstore.Blockstore, ds format.DAGService, repo repo.Repo) (pin.Pinner, error) { +func Pinning(mctx helpers.MetricsCtx, lc fx.Lifecycle, bstore blockstore.Blockstore, ds format.DAGService, repo repo.Repo) (pin.Pinner, error) { internalDag := merkledag.NewDAGService(blockservice.New(bstore, offline.Exchange(bstore))) rootDS := repo.Datastore() - syncFn := func() error { - if err := rootDS.Sync(blockstore.BlockPrefix); err != nil { + syncFn := func(ctx context.Context) error { + if err := rootDS.Sync(ctx, blockstore.BlockPrefix); err != nil { return err } - return rootDS.Sync(filestore.FilestorePrefix) + return rootDS.Sync(ctx, filestore.FilestorePrefix) } syncDs := &syncDagService{ds, syncFn} syncInternalDag := &syncDagService{internalDag, syncFn} - pinning, err := pin.LoadPinner(rootDS, syncDs, syncInternalDag) + ctx := helpers.LifecycleCtx(mctx, lc) + pinning, err := pin.LoadPinner(ctx, rootDS, syncDs, syncInternalDag) if err != nil { // TODO: we should move towards only running 'NewPinner' explicitly on // node init instead of implicitly here as a result of the pinner keys @@ -73,11 +74,11 @@ var ( // syncDagService is used by the Pinner to ensure data gets persisted to the underlying datastore type syncDagService struct { format.DAGService - syncFn func() error + syncFn func(ctx context.Context) error } -func (s *syncDagService) Sync() error { - return s.syncFn() +func (s *syncDagService) Sync(ctx context.Context) error { + return s.syncFn(ctx) } func (s *syncDagService) Session(ctx context.Context) format.NodeGetter { @@ -109,22 +110,22 @@ func Files(mctx helpers.MetricsCtx, lc fx.Lifecycle, repo repo.Repo, dag format. dsk := datastore.NewKey("/local/filesroot") pf := func(ctx context.Context, c cid.Cid) error { rootDS := repo.Datastore() - if err := rootDS.Sync(blockstore.BlockPrefix); err != nil { + if err := rootDS.Sync(ctx, blockstore.BlockPrefix); err != nil { return err } - if err := rootDS.Sync(filestore.FilestorePrefix); err != nil { + if err := rootDS.Sync(ctx, filestore.FilestorePrefix); err != nil { return err } - if err := rootDS.Put(dsk, c.Bytes()); err != nil { + if err := rootDS.Put(ctx, dsk, c.Bytes()); err != nil { return err } - return rootDS.Sync(dsk) + return rootDS.Sync(ctx, dsk) } var nd *merkledag.ProtoNode - val, err := repo.Datastore().Get(dsk) ctx := helpers.LifecycleCtx(mctx, lc) + val, err := repo.Datastore().Get(ctx, dsk) switch { case err == datastore.ErrNotFound || val == nil: diff --git a/gc/gc.go b/gc/gc.go index 4b0e6c5d790..efda09734be 100644 --- a/gc/gc.go +++ b/gc/gc.go @@ -80,7 +80,7 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn break loop } if !gcs.Has(k) { - err := bs.DeleteBlock(k) + err := bs.DeleteBlock(ctx, k) removed++ if err != nil { errors = true diff --git a/go.mod b/go.mod index fa9dc16a0dd..8878106b94b 100644 --- a/go.mod +++ b/go.mod @@ -29,11 +29,11 @@ require ( github.com/ipfs/go-filestore v0.0.3 github.com/ipfs/go-fs-lock v0.0.5 github.com/ipfs/go-graphsync v0.0.5 - github.com/ipfs/go-ipfs-blockstore v0.1.4 + github.com/ipfs/go-ipfs-blockstore v1.0.0 github.com/ipfs/go-ipfs-chunker v0.0.5 github.com/ipfs/go-ipfs-cmds v0.2.9 github.com/ipfs/go-ipfs-config v0.9.0 - github.com/ipfs/go-ipfs-ds-help v0.1.1 + github.com/ipfs/go-ipfs-ds-help v1.0.0 github.com/ipfs/go-ipfs-exchange-interface v0.0.1 github.com/ipfs/go-ipfs-exchange-offline v0.0.1 github.com/ipfs/go-ipfs-files v0.0.8 @@ -115,4 +115,25 @@ require ( gopkg.in/cheggaaa/pb.v1 v1.0.28 ) +replace ( + github.com/ipfs/go-bitswap => github.com/MichaelMure/go-bitswap v0.2.20-0.20200720173351-71e8bd0a1b1a + github.com/ipfs/go-blockservice => github.com/MichaelMure/go-blockservice v0.1.4-0.20200720174746-aaf978f8c7e2 + github.com/ipfs/go-datastore => github.com/MichaelMure/go-datastore v0.1.1-0.20200720160526-a840b6a243a7 + github.com/ipfs/go-ds-badger => github.com/MichaelMure/go-ds-badger v0.0.8-0.20200720160655-efad091216d6 + github.com/ipfs/go-ds-flatfs => github.com/MichaelMure/go-ds-flatfs v0.1.1-0.20200720153411-098af07a315f + github.com/ipfs/go-ds-leveldb => github.com/MichaelMure/go-ds-leveldb v0.1.1-0.20200720161456-f8de4f0cb528 + github.com/ipfs/go-ds-measure => github.com/MichaelMure/go-ds-measure v0.0.2-0.20200720154401-7670e7876069 + github.com/ipfs/go-filestore => github.com/MichaelMure/go-filestore v1.0.1-0.20200720201744-9d0dd571946e + github.com/ipfs/go-ipfs-blockstore => github.com/MichaelMure/go-ipfs-blockstore v1.0.1-0.20200720163520-6daba4f3daa0 + github.com/ipfs/go-ipfs-exchange-interface => github.com/MichaelMure/go-ipfs-exchange-interface v0.0.2-0.20200720171619-b6887ed2e001 + github.com/ipfs/go-ipfs-exchange-offline => github.com/MichaelMure/go-ipfs-exchange-offline v0.0.2-0.20200720172012-8e028686ae1e + github.com/ipfs/go-ipfs-provider => github.com/MichaelMure/go-ipfs-provider v0.2.2-0.20200720181729-c6b88a2c5d79 + github.com/ipfs/go-ipfs-routing => github.com/MichaelMure/go-ipfs-routing v0.1.1-0.20200720164918-a1a2e00f1a0e + github.com/ipfs/go-merkledag => github.com/MichaelMure/go-merkledag v0.2.1-0.20200720175629-7f5b5e19fa8c + github.com/libp2p/go-libp2p-kad-dht => github.com/MichaelMure/go-libp2p-kad-dht v0.0.0-20200721082318-ffb18adb50cb + github.com/ipfs/go-ipfs-pinner => github.com/MichaelMure/go-ipfs-pinner v0.0.0-20200721082940-4cae5f9fa49d + github.com/libp2p/go-libp2p-pubsub-router => github.com/MichaelMure/go-libp2p-pubsub-router v0.3.1-0.20200722090547-ec92a4e5678b + github.com/ipfs/go-graphsync => github.com/MichaelMure/go-graphsync v0.0.6-0.20200722092520-d944aa3c7da9 +) + go 1.13 diff --git a/go.sum b/go.sum index 6662a335dbc..f79ca06de01 100644 --- a/go.sum +++ b/go.sum @@ -33,6 +33,42 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Kubuxu/go-os-helper v0.0.1 h1:EJiD2VUQyh5A9hWJLmc6iWg6yIcJ7jpBcwC8GMGXfDk= github.com/Kubuxu/go-os-helper v0.0.1/go.mod h1:N8B+I7vPCT80IcP58r50u4+gEEcsZETFUpAzWW2ep1Y= +github.com/MichaelMure/go-bitswap v0.2.20-0.20200720173351-71e8bd0a1b1a h1:mQhIo2vkI9aeO0iW32Ak2ITV5789oR+2vdWAgghY3mU= +github.com/MichaelMure/go-bitswap v0.2.20-0.20200720173351-71e8bd0a1b1a/go.mod h1:C7TwBgHnu89Q8sHsTJP7IhUqF9XYLe71P4tT5adgmYo= +github.com/MichaelMure/go-blockservice v0.1.4-0.20200720174746-aaf978f8c7e2 h1:493KOX8Be8/HxTg/g9uz3zXgtD/Kl09okcldjTkEURs= +github.com/MichaelMure/go-blockservice v0.1.4-0.20200720174746-aaf978f8c7e2/go.mod h1:OTZhFpkgY48kNzbgyvcexW9cHrpjBYIjSR0KoDOFOLU= +github.com/MichaelMure/go-datastore v0.1.1-0.20200720160526-a840b6a243a7 h1:X23hY6XlqC+yHBlTJFMR6vNwZfj8VaLwaLl7fOgHnro= +github.com/MichaelMure/go-datastore v0.1.1-0.20200720160526-a840b6a243a7/go.mod h1:eXTcaaiN6uOlVCLS9GjJUJtlvJfM3xk23w3fyfrmmJs= +github.com/MichaelMure/go-ds-badger v0.0.8-0.20200720160655-efad091216d6 h1:7MNPN3wswmS8lq89rN4CEnp7fZVqlv4BBW6BRV+AAas= +github.com/MichaelMure/go-ds-badger v0.0.8-0.20200720160655-efad091216d6/go.mod h1:Y2ir78DHbgA/5JcyWBo7eoQWzRABZvA9qXomZbO018s= +github.com/MichaelMure/go-ds-flatfs v0.1.1-0.20200720153411-098af07a315f h1:VwzUCM8g8Qefs3Lie0P6Z5kS+h9SLrXwTi/6YxfcN/0= +github.com/MichaelMure/go-ds-flatfs v0.1.1-0.20200720153411-098af07a315f/go.mod h1:e4TesLyZoA8k1gV/yCuBTnt2PJtypn4XUlB5n8KQMZY= +github.com/MichaelMure/go-ds-leveldb v0.1.1-0.20200720161456-f8de4f0cb528 h1:EvX515rSwuFD78u/WBwLp0d4Gm4nVPjk6HwHB95hHMM= +github.com/MichaelMure/go-ds-leveldb v0.1.1-0.20200720161456-f8de4f0cb528/go.mod h1:jpbku/YqBSsBc1qgME8BkWS4AxzF2cEu1Ii2r79Hh9s= +github.com/MichaelMure/go-ds-measure v0.0.2-0.20200720154401-7670e7876069 h1:B1jhXi32lvebiwXKDIeW9JWOqZEIGpeRaEKnPnyAS5w= +github.com/MichaelMure/go-ds-measure v0.0.2-0.20200720154401-7670e7876069/go.mod h1:AZjhT5Y8h/8ebsb51TjiePp5wim1X4yykW2/ZunRF3Y= +github.com/MichaelMure/go-filestore v1.0.1-0.20200720201744-9d0dd571946e h1:9/tcxifX2E/BvBZKpCcEHE5mPcLoB02ILmuvAlS4JR8= +github.com/MichaelMure/go-filestore v1.0.1-0.20200720201744-9d0dd571946e/go.mod h1:/XOCuNtIe2f1YPbiXdYvD0BKLA0JR1MgPiFOdcuu9SM= +github.com/MichaelMure/go-graphsync v0.0.6-0.20200722092520-d944aa3c7da9 h1:CvggQUdBIgwZ4CYVThs2aJZ5yJU22mcfULI+UmuEWTM= +github.com/MichaelMure/go-graphsync v0.0.6-0.20200722092520-d944aa3c7da9/go.mod h1:SGKa4rVgCCz3KDNqe38wLEDYFa/PUF6w/ertGSQk33I= +github.com/MichaelMure/go-ipfs-blockstore v1.0.1-0.20200720163520-6daba4f3daa0 h1:xqwIkEF3biwYfcBIWC1sDZUN063n4gHfQQIdVfU3Bn4= +github.com/MichaelMure/go-ipfs-blockstore v1.0.1-0.20200720163520-6daba4f3daa0/go.mod h1:HcfZNYF1gyavVZyF/E/WX6ARa9/YysSeqJzQ3LTNXyg= +github.com/MichaelMure/go-ipfs-exchange-interface v0.0.2-0.20200720171619-b6887ed2e001 h1:PrB7WI2mDjMNMYkMymEVxDp5+OPK3WuHUKBiO3Yb//A= +github.com/MichaelMure/go-ipfs-exchange-interface v0.0.2-0.20200720171619-b6887ed2e001/go.mod h1:FoGeD52vvvNC/sx4affojmVKafjg5AI3Z6okMpGH7ns= +github.com/MichaelMure/go-ipfs-exchange-offline v0.0.2-0.20200720172012-8e028686ae1e h1:a2xXqr1eqJkQUpQe9Hbu+toi3mAb3ZFvCC5jhnEfNXU= +github.com/MichaelMure/go-ipfs-exchange-offline v0.0.2-0.20200720172012-8e028686ae1e/go.mod h1:lamM060WYjcDQHhRGFnaNoIJdFErf4Wki+t+AiluILA= +github.com/MichaelMure/go-ipfs-pinner v0.0.0-20200721082940-4cae5f9fa49d h1:tipzvoA79vh77ObkZJGsmh1TLv+D1baw9n0gPbnbB8U= +github.com/MichaelMure/go-ipfs-pinner v0.0.0-20200721082940-4cae5f9fa49d/go.mod h1:s4kFZWLWGDudN8Jyd/GTpt222A12C2snA2+OTdy/7p8= +github.com/MichaelMure/go-ipfs-provider v0.2.2-0.20200720181729-c6b88a2c5d79 h1:lPwpsgAMK4X9svxqbLRt+jdSh6Mfwn4etzias263F8g= +github.com/MichaelMure/go-ipfs-provider v0.2.2-0.20200720181729-c6b88a2c5d79/go.mod h1:rcQBVqfblDQRk5LaCtf2uxuKxMJxvKmF5pLS0pO4au4= +github.com/MichaelMure/go-ipfs-routing v0.1.1-0.20200720164918-a1a2e00f1a0e h1:OZ99Ej9X7aGQHQrkCmhU/4IofDvdg27avubnk3c42r8= +github.com/MichaelMure/go-ipfs-routing v0.1.1-0.20200720164918-a1a2e00f1a0e/go.mod h1:hYoUkJLyAUKhF58tysKpids8RNDPO42BVMgK5dNsoqY= +github.com/MichaelMure/go-libp2p-kad-dht v0.0.0-20200721082318-ffb18adb50cb h1:U9HksKE4jH9aiTYXVp/h+A0tTZBmHdQqcyjZKTlGzwg= +github.com/MichaelMure/go-libp2p-kad-dht v0.0.0-20200721082318-ffb18adb50cb/go.mod h1:u3rbYbp3CSraAHD5s81CJ3hHozKTud/UOXfAgh93Gek= +github.com/MichaelMure/go-libp2p-pubsub-router v0.3.1-0.20200722090547-ec92a4e5678b h1:WwB1375zLME5OvIbfdqMNWMyEbFO3pqheTCuql8dPyg= +github.com/MichaelMure/go-libp2p-pubsub-router v0.3.1-0.20200722090547-ec92a4e5678b/go.mod h1:6kZb1gGV1yGzXTfyNsi4p+hyt1JnA1OMGHeExTOJR3A= +github.com/MichaelMure/go-merkledag v0.2.1-0.20200720175629-7f5b5e19fa8c h1:zxMTorOpMfBbZ6tzGUNPxVoEbNczjY3JxzBmSD7SH7s= +github.com/MichaelMure/go-merkledag v0.2.1-0.20200720175629-7f5b5e19fa8c/go.mod h1:fvkZNNZixVW6cKSZ/JfLlON5OlgTXNdRLz0p6QG/I2M= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Stebalien/go-bitfield v0.0.0-20180330043415-076a62f9ce6e/go.mod h1:3oM7gXIttpYDAJXpVNnSCiUMYBLIZ6cb1t+Ip982MRo= @@ -227,6 +263,7 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c h1:7lF+Vz0LqiRidnzC1Oq86fpX1q/iEv2KJdrCtttYjT4= github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= @@ -237,6 +274,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpg github.com/gxed/hashland/keccakpg v0.0.1/go.mod h1:kRzw3HkwxFU1mpmPP8v1WyQzwdGfmKFJ6tItnhQ67kU= github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48= github.com/gxed/pubsub v0.0.0-20180201040156-26ebdf44f824/go.mod h1:OiEWyHgK+CWrmOlVquHaIK1vhpUJydC9m0Je6mhaiNE= +github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e h1:3YKHER4nmd7b5qy5t0GWDTwSn4OyRgfAXSmo6VnryBY= +github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e/go.mod h1:I8h3MITA53gN9OnWGCgaMa0JWVRdXthWw4M3CPM54OY= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI= @@ -357,6 +396,8 @@ github.com/ipfs/go-ipfs-ds-help v0.0.1 h1:QBg+Ts2zgeemK/dB0saiF/ykzRGgfoFMT90Rzo github.com/ipfs/go-ipfs-ds-help v0.0.1/go.mod h1:gtP9xRaZXqIQRh1HRpp595KbBEdgqWFxefeVKOV8sxo= github.com/ipfs/go-ipfs-ds-help v0.1.1 h1:IW/bXGeaAZV2VH0Kuok+Ohva/zHkHmeLFBxC1k7mNPc= github.com/ipfs/go-ipfs-ds-help v0.1.1/go.mod h1:SbBafGJuGsPI/QL3j9Fc5YPLeAu+SzOkI0gFwAg+mOs= +github.com/ipfs/go-ipfs-ds-help v1.0.0 h1:bEQ8hMGs80h0sR8O4tfDgV6B01aaF9qeTrujrTLYV3g= +github.com/ipfs/go-ipfs-ds-help v1.0.0/go.mod h1:ujAbkeIgkKAWtxxNkoZHWLCyk5JpPoKnGyCcsoF6ueE= github.com/ipfs/go-ipfs-exchange-interface v0.0.1 h1:LJXIo9W7CAmugqI+uofioIpRb6rY30GUu7G6LUfpMvM= github.com/ipfs/go-ipfs-exchange-interface v0.0.1/go.mod h1:c8MwfHjtQjPoDyiy9cFquVtVHkO9b9Ob3FG91qJnWCM= github.com/ipfs/go-ipfs-exchange-offline v0.0.1 h1:P56jYKZF7lDDOLx5SotVh5KFxoY6C81I1NSHW1FxGew= @@ -457,8 +498,13 @@ github.com/ipld/go-car v0.1.0 h1:AaIEA5ITRnFA68uMyuIPYGM2XXllxsu8sNjFJP797us= github.com/ipld/go-car v0.1.0/go.mod h1:RCWzaUh2i4mOEkB3W45Vc+9jnS/M6Qay5ooytiBHl3g= github.com/ipld/go-ipld-prime v0.0.2-0.20191108012745-28a82f04c785 h1:fASnkvtR+SmB2y453RxmDD3Uvd4LonVUgFGk9JoDaZs= github.com/ipld/go-ipld-prime v0.0.2-0.20191108012745-28a82f04c785/go.mod h1:bDDSvVz7vaK12FNvMeRYnpRFkSUPNQOiCYQezMD/P3w= +github.com/ipld/go-ipld-prime v0.0.2-0.20200428162820-8b59dc292b8e h1:ZISbJlM0urTANR9KRfRaqlBmyOj5uUtxs2r4Up9IXsA= +github.com/ipld/go-ipld-prime v0.0.2-0.20200428162820-8b59dc292b8e/go.mod h1:uVIwe/u0H4VdKv3kaN1ck7uCb6yD9cFLS9/ELyXbsw8= +github.com/ipld/go-ipld-prime v0.5.0 h1:kr3nB6/JcFpc3Yj7vveXYuiVyZJzWUkJyLMjQbnoswE= github.com/ipld/go-ipld-prime-proto v0.0.0-20191113031812-e32bd156a1e5 h1:lSip43rAdyGA+yRQuy6ju0ucZkWpYc1F2CTQtZTVW/4= github.com/ipld/go-ipld-prime-proto v0.0.0-20191113031812-e32bd156a1e5/go.mod h1:gcvzoEDBjwycpXt3LBE061wT9f46szXGHAmj9uoP6fU= +github.com/ipld/go-ipld-prime-proto v0.0.0-20200428191222-c1ffdadc01e1 h1:K1Ysr7kgIlo7YQkPqdkA6H7BVdIugvuAz7OQUTJxLdE= +github.com/ipld/go-ipld-prime-proto v0.0.0-20200428191222-c1ffdadc01e1/go.mod h1:OAV6xBmuTLsPZ+epzKkPB1e25FHk/vCtyatkdHcArLs= github.com/jackpal/gateway v1.0.4/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA= github.com/jackpal/gateway v1.0.5 h1:qzXWUJfuMdlLMtt0a3Dgt+xkWQiA5itDEITVJtuSwMc= github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA= @@ -720,6 +766,7 @@ github.com/libp2p/go-libp2p-quic-transport v0.7.1 h1:X6Ond9GANspXpgwJlSR9yxcMMD6 github.com/libp2p/go-libp2p-quic-transport v0.7.1/go.mod h1:TD31to4E5exogR/GWHClXCfkktigjAl5rXSt7HoxNvY= github.com/libp2p/go-libp2p-record v0.0.1/go.mod h1:grzqg263Rug/sRex85QrDOLntdFAymLDLm7lxMgU79Q= github.com/libp2p/go-libp2p-record v0.1.0/go.mod h1:ujNc8iuE5dlKWVy6wuL6dd58t0n7xI4hAIl8pE6wu5Q= +github.com/libp2p/go-libp2p-record v0.1.1/go.mod h1:VRgKajOyMVgP/F0L5g3kH7SVskp17vFi2xheb5uMJtg= github.com/libp2p/go-libp2p-record v0.1.2 h1:M50VKzWnmUrk/M5/Dz99qO9Xh4vs8ijsK+7HkJvRP+0= github.com/libp2p/go-libp2p-record v0.1.2/go.mod h1:pal0eNcT5nqZaTV7UGhqeGqxFgGdsU/9W//C8dqjQDk= github.com/libp2p/go-libp2p-record v0.1.3 h1:R27hoScIhQf/A8XJZ8lYpnqh9LatJ5YbHs28kCIfql0= @@ -1027,6 +1074,9 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/polydawn/refmt v0.0.0-20190221155625-df39d6c2d992/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o= github.com/polydawn/refmt v0.0.0-20190408063855-01bf1e26dd14 h1:2m16U/rLwVaRdz7ANkHtHTodP3zTP3N451MADg64x5k= github.com/polydawn/refmt v0.0.0-20190408063855-01bf1e26dd14/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o= +github.com/polydawn/refmt v0.0.0-20190807091052-3d65705ee9f1/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o= +github.com/polydawn/refmt v0.0.0-20190809202753-05966cbd336a h1:hjZfReYVLbqFkAtr2us7vdy04YWz3LVAirzP7reh8+M= +github.com/polydawn/refmt v0.0.0-20190809202753-05966cbd336a/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o= github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= @@ -1083,11 +1133,13 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v1.0.0 h1:UVQPSSmc3qtTi+zPPkCXvZX9VvW/xT/NsRvKfwY81a8= github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= +github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= github.com/smartystreets/goconvey v0.0.0-20190222223459-a17d461953aa/go.mod h1:2RVY1rIf+2J2o/IM9+vPq9RzmHDSseB7FoXiSNIUsoU= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a h1:pa8hGb/2YqsZKovtsgrwcDH1RZhVbTKCjLp47XpqCDs= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/smartystreets/goconvey v0.0.0-20190710185942-9d28bd7c0945 h1:N8Bg45zpk/UcpNGnfJt2y/3lRWASHNTUET8owPYCgYI= github.com/smartystreets/goconvey v0.0.0-20190710185942-9d28bd7c0945/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/smola/gocompat v0.2.0 h1:6b1oIMlUXIpz//VKEDzPVBK8KG7beVwmHIUEBIs/Pns= github.com/smola/gocompat v0.2.0/go.mod h1:1B0MlxbmoZNo3h8guHp8HztB3BSYR5itql9qtVc0ypY= github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE= @@ -1130,10 +1182,13 @@ github.com/wangjia184/sortedset v0.0.0-20160527075905-f5d03557ba30/go.mod h1:Yko github.com/warpfork/go-wish v0.0.0-20180510122957-5ad1f5abf436/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= github.com/warpfork/go-wish v0.0.0-20190328234359-8b3e70f8e830 h1:8kxMKmKzXXL4Ru1nyhvdms/JjWt+3YLpvRb/bAjO/y0= github.com/warpfork/go-wish v0.0.0-20190328234359-8b3e70f8e830/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= +github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc h1:BCPnHtcboadS0DvysUuJXZ4lWVv5Bh5i7+tbIyi+ck4= github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc/go.mod h1:r45hJU7yEoA81k6MWNhpMj/kms0n14dkzkxYHoB96UM= github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158 h1:WXhVOwj2USAXB5oMDwRl3piOux2XMV9TANaYxXHdkoE= github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI= +github.com/whyrusleeping/cbor-gen v0.0.0-20200402171437-3d27c146c105 h1:Sh6UG5dW5xW8Ek2CtRGq4ipdEvvx9hOyBJjEGyTYDl0= +github.com/whyrusleeping/cbor-gen v0.0.0-20200402171437-3d27c146c105/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f/go.mod h1:p9UJB6dDgdPgMJZs7UjUOdulKyRr9fqkS+6JKAInPy8= github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k= @@ -1226,6 +1281,7 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200117160349-530e935923ad/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5 h1:Q7tZBpemrlsc2I7IyODzhtallWRSm4Q0d09pL6XbQtU= @@ -1352,6 +1408,7 @@ golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191210023423-ac6580df4449/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= diff --git a/namesys/publisher.go b/namesys/publisher.go index f558eaf2885..8f9bfdd463c 100644 --- a/namesys/publisher.go +++ b/namesys/publisher.go @@ -59,7 +59,7 @@ func IpnsDsKey(id peer.ID) ds.Key { // This method will not search the routing system for records published by other // nodes. func (p *IpnsPublisher) ListPublished(ctx context.Context) (map[peer.ID]*pb.IpnsEntry, error) { - query, err := p.ds.Query(dsquery.Query{ + query, err := p.ds.Query(ctx, dsquery.Query{ Prefix: ipnsPrefix, }) if err != nil { @@ -109,7 +109,7 @@ func (p *IpnsPublisher) GetPublished(ctx context.Context, id peer.ID, checkRouti ctx, cancel := context.WithTimeout(ctx, time.Second*30) defer cancel() - value, err := p.ds.Get(IpnsDsKey(id)) + value, err := p.ds.Get(ctx, IpnsDsKey(id)) switch err { case nil: case ds.ErrNotFound: @@ -179,10 +179,10 @@ func (p *IpnsPublisher) updateRecord(ctx context.Context, k ci.PrivKey, value pa // Put the new record. key := IpnsDsKey(id) - if err := p.ds.Put(key, data); err != nil { + if err := p.ds.Put(ctx, key, data); err != nil { return nil, err } - if err := p.ds.Sync(key); err != nil { + if err := p.ds.Sync(ctx, key); err != nil { return nil, err } return entry, nil diff --git a/namesys/publisher_test.go b/namesys/publisher_test.go index 62510338353..2caf630b00f 100644 --- a/namesys/publisher_test.go +++ b/namesys/publisher_test.go @@ -94,7 +94,7 @@ func testNamekeyPublisher(t *testing.T, keyType int, expectedErr error, expected // Also check datastore for completeness key := dshelp.NewKeyFromBinary([]byte(namekey)) - exists, err := dstore.Has(key) + exists, err := dstore.Has(ctx, key) if err != nil { t.Fatal(err) } @@ -149,7 +149,7 @@ type checkSyncDS struct { syncKeys map[ds.Key]struct{} } -func (d *checkSyncDS) Sync(prefix ds.Key) error { +func (d *checkSyncDS) Sync(ctx context.Context, prefix ds.Key) error { d.syncKeys[prefix] = struct{}{} - return d.Datastore.Sync(prefix) + return d.Datastore.Sync(ctx, prefix) } diff --git a/namesys/republisher/repub.go b/namesys/republisher/repub.go index 9e7272d32e0..48351a68a7b 100644 --- a/namesys/republisher/repub.go +++ b/namesys/republisher/repub.go @@ -126,7 +126,7 @@ func (rp *Republisher) republishEntry(ctx context.Context, priv ic.PrivKey) erro log.Debugf("republishing ipns entry for %s", id) // Look for it locally only - p, err := rp.getLastVal(id) + p, err := rp.getLastVal(ctx, id) if err != nil { if err == errNoEntry { return nil @@ -139,9 +139,9 @@ func (rp *Republisher) republishEntry(ctx context.Context, priv ic.PrivKey) erro return rp.ns.PublishWithEOL(ctx, priv, p, eol) } -func (rp *Republisher) getLastVal(id peer.ID) (path.Path, error) { +func (rp *Republisher) getLastVal(ctx context.Context, id peer.ID) (path.Path, error) { // Look for it locally only - val, err := rp.ds.Get(namesys.IpnsDsKey(id)) + val, err := rp.ds.Get(ctx, namesys.IpnsDsKey(id)) switch err { case nil: case ds.ErrNotFound: diff --git a/repo/fsrepo/fsrepo_test.go b/repo/fsrepo/fsrepo_test.go index 63bd11fd185..795f37308a1 100644 --- a/repo/fsrepo/fsrepo_test.go +++ b/repo/fsrepo/fsrepo_test.go @@ -2,6 +2,7 @@ package fsrepo import ( "bytes" + "context" "io/ioutil" "os" "path/filepath" @@ -65,6 +66,7 @@ func TestCanManageReposIndependently(t *testing.T) { func TestDatastoreGetNotAllowedAfterClose(t *testing.T) { t.Parallel() + ctx := context.Background() path := testRepoPath("test", t) assert.True(!IsInitialized(path), t, "should NOT be initialized") @@ -74,15 +76,16 @@ func TestDatastoreGetNotAllowedAfterClose(t *testing.T) { k := "key" data := []byte(k) - assert.Nil(r.Datastore().Put(datastore.NewKey(k), data), t, "Put should be successful") + assert.Nil(r.Datastore().Put(ctx, datastore.NewKey(k), data), t, "Put should be successful") assert.Nil(r.Close(), t) - _, err = r.Datastore().Get(datastore.NewKey(k)) + _, err = r.Datastore().Get(ctx, datastore.NewKey(k)) assert.Err(err, t, "after closer, Get should be fail") } func TestDatastorePersistsFromRepoToRepo(t *testing.T) { t.Parallel() + ctx := context.Background() path := testRepoPath("test", t) assert.Nil(Init(path, &config.Config{Datastore: config.DefaultDatastoreConfig()}), t) @@ -91,12 +94,12 @@ func TestDatastorePersistsFromRepoToRepo(t *testing.T) { k := "key" expected := []byte(k) - assert.Nil(r1.Datastore().Put(datastore.NewKey(k), expected), t, "using first repo, Put should be successful") + assert.Nil(r1.Datastore().Put(ctx, datastore.NewKey(k), expected), t, "using first repo, Put should be successful") assert.Nil(r1.Close(), t) r2, err := Open(path) assert.Nil(err, t) - actual, err := r2.Datastore().Get(datastore.NewKey(k)) + actual, err := r2.Datastore().Get(ctx, datastore.NewKey(k)) assert.Nil(err, t, "using second repo, Get should be successful") assert.Nil(r2.Close(), t) assert.True(bytes.Equal(expected, actual), t, "data should match") diff --git a/test/integration/bitswap_wo_routing_test.go b/test/integration/bitswap_wo_routing_test.go index d854f3a6b28..31f51a62773 100644 --- a/test/integration/bitswap_wo_routing_test.go +++ b/test/integration/bitswap_wo_routing_test.go @@ -61,7 +61,7 @@ func TestBitswapWithoutRouting(t *testing.T) { block1 := blocks.NewBlock([]byte("block1")) // put 1 before - if err := nodes[0].Blockstore.Put(block0); err != nil { + if err := nodes[0].Blockstore.Put(ctx, block0); err != nil { t.Fatal(err) } @@ -84,7 +84,7 @@ func TestBitswapWithoutRouting(t *testing.T) { } // put 1 after - if err := nodes[1].Blockstore.Put(block1); err != nil { + if err := nodes[1].Blockstore.Put(ctx, block1); err != nil { t.Fatal(err) } diff --git a/thirdparty/cidv0v1/blockstore.go b/thirdparty/cidv0v1/blockstore.go index 2f098dff9fe..f28feae7560 100644 --- a/thirdparty/cidv0v1/blockstore.go +++ b/thirdparty/cidv0v1/blockstore.go @@ -1,6 +1,8 @@ package cidv0v1 import ( + "context" + blocks "github.com/ipfs/go-block-format" cid "github.com/ipfs/go-cid" bs "github.com/ipfs/go-ipfs-blockstore" @@ -15,8 +17,8 @@ func NewBlockstore(b bs.Blockstore) bs.Blockstore { return &blockstore{b} } -func (b *blockstore) Has(c cid.Cid) (bool, error) { - have, err := b.Blockstore.Has(c) +func (b *blockstore) Has(ctx context.Context, c cid.Cid) (bool, error) { + have, err := b.Blockstore.Has(ctx, c) if have || err != nil { return have, err } @@ -24,11 +26,11 @@ func (b *blockstore) Has(c cid.Cid) (bool, error) { if !c1.Defined() { return false, nil } - return b.Blockstore.Has(c1) + return b.Blockstore.Has(ctx, c1) } -func (b *blockstore) Get(c cid.Cid) (blocks.Block, error) { - block, err := b.Blockstore.Get(c) +func (b *blockstore) Get(ctx context.Context, c cid.Cid) (blocks.Block, error) { + block, err := b.Blockstore.Get(ctx, c) if err == nil { return block, nil } @@ -39,7 +41,7 @@ func (b *blockstore) Get(c cid.Cid) (blocks.Block, error) { if !c1.Defined() { return nil, bs.ErrNotFound } - block, err = b.Blockstore.Get(c1) + block, err = b.Blockstore.Get(ctx, c1) if err != nil { return nil, err } @@ -50,15 +52,15 @@ func (b *blockstore) Get(c cid.Cid) (blocks.Block, error) { } // insert the block with the original CID to avoid problems // with pinning - err = b.Blockstore.Put(block) + err = b.Blockstore.Put(ctx, block) if err != nil { return nil, err } return block, nil } -func (b *blockstore) GetSize(c cid.Cid) (int, error) { - size, err := b.Blockstore.GetSize(c) +func (b *blockstore) GetSize(ctx context.Context, c cid.Cid) (int, error) { + size, err := b.Blockstore.GetSize(ctx, c) if err == nil { return size, nil } @@ -69,7 +71,7 @@ func (b *blockstore) GetSize(c cid.Cid) (int, error) { if !c1.Defined() { return -1, bs.ErrNotFound } - return b.Blockstore.GetSize(c1) + return b.Blockstore.GetSize(ctx, c1) } func tryOtherCidVersion(c cid.Cid) cid.Cid { diff --git a/thirdparty/verifbs/verifbs.go b/thirdparty/verifbs/verifbs.go index 53b6d13ca77..7be5348a82c 100644 --- a/thirdparty/verifbs/verifbs.go +++ b/thirdparty/verifbs/verifbs.go @@ -1,6 +1,8 @@ package verifbs import ( + "context" + blocks "github.com/ipfs/go-block-format" cid "github.com/ipfs/go-cid" bstore "github.com/ipfs/go-ipfs-blockstore" @@ -11,52 +13,52 @@ type VerifBSGC struct { bstore.GCBlockstore } -func (bs *VerifBSGC) Put(b blocks.Block) error { +func (bs *VerifBSGC) Put(ctx context.Context, b blocks.Block) error { if err := verifcid.ValidateCid(b.Cid()); err != nil { return err } - return bs.GCBlockstore.Put(b) + return bs.GCBlockstore.Put(ctx, b) } -func (bs *VerifBSGC) PutMany(blks []blocks.Block) error { +func (bs *VerifBSGC) PutMany(ctx context.Context, blks []blocks.Block) error { for _, b := range blks { if err := verifcid.ValidateCid(b.Cid()); err != nil { return err } } - return bs.GCBlockstore.PutMany(blks) + return bs.GCBlockstore.PutMany(ctx, blks) } -func (bs *VerifBSGC) Get(c cid.Cid) (blocks.Block, error) { +func (bs *VerifBSGC) Get(ctx context.Context, c cid.Cid) (blocks.Block, error) { if err := verifcid.ValidateCid(c); err != nil { return nil, err } - return bs.GCBlockstore.Get(c) + return bs.GCBlockstore.Get(ctx, c) } type VerifBS struct { bstore.Blockstore } -func (bs *VerifBS) Put(b blocks.Block) error { +func (bs *VerifBS) Put(ctx context.Context, b blocks.Block) error { if err := verifcid.ValidateCid(b.Cid()); err != nil { return err } - return bs.Blockstore.Put(b) + return bs.Blockstore.Put(ctx, b) } -func (bs *VerifBS) PutMany(blks []blocks.Block) error { +func (bs *VerifBS) PutMany(ctx context.Context, blks []blocks.Block) error { for _, b := range blks { if err := verifcid.ValidateCid(b.Cid()); err != nil { return err } } - return bs.Blockstore.PutMany(blks) + return bs.Blockstore.PutMany(ctx, blks) } -func (bs *VerifBS) Get(c cid.Cid) (blocks.Block, error) { +func (bs *VerifBS) Get(ctx context.Context, c cid.Cid) (blocks.Block, error) { if err := verifcid.ValidateCid(c); err != nil { return nil, err } - return bs.Blockstore.Get(c) + return bs.Blockstore.Get(ctx, c) }