Skip to content

Commit

Permalink
fix: remove github.com/ipfs/go-ipfs-blockstore dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed May 31, 2023
1 parent a54f267 commit 3f39582
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion v2/blockstore/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
// * blockstore.GetSize will always succeed, returning the multihash digest length of the given CID.
// * blockstore.Put and blockstore.PutMany will always succeed without performing any operation unless car.StoreIdentityCIDs is enabled.
//
// See: https://pkg.go.dev/github.com/ipfs/go-ipfs-blockstore#NewIdStore
// See: https://pkg.go.dev/github.com/ipfs/boxo/blockstore#NewIdStore
package blockstore
16 changes: 14 additions & 2 deletions v2/blockstore/readonly.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
blockstore "github.com/ipfs/go-ipfs-blockstore"
format "github.com/ipfs/go-ipld-format"
carv2 "github.com/ipld/go-car/v2"
"github.com/ipld/go-car/v2/index"
Expand All @@ -20,7 +19,20 @@ import (
"golang.org/x/exp/mmap"
)

var _ blockstore.Blockstore = (*ReadOnly)(nil)
// Blockstore is compatible with github.com/ipfs/go-ipfs-blockstore.Blockstore
// and github.com/ipfs/boxo/blockstore.Blockstore.
type Blockstore interface {
DeleteBlock(context.Context, cid.Cid) error
Has(context.Context, cid.Cid) (bool, error)
Get(context.Context, cid.Cid) (blocks.Block, error)
GetSize(context.Context, cid.Cid) (int, error)
Put(context.Context, blocks.Block) error
PutMany(context.Context, []blocks.Block) error
AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
HashOnRead(enabled bool)
}

var _ Blockstore = (*ReadOnly)(nil)

var (
errZeroLengthSection = fmt.Errorf("zero-length carv2 section not allowed by default; see WithZeroLengthSectionAsEOF option")
Expand Down
3 changes: 1 addition & 2 deletions v2/blockstore/readwrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
blockstore "github.com/ipfs/go-ipfs-blockstore"

carv2 "github.com/ipld/go-car/v2"
"github.com/ipld/go-car/v2/index"
Expand All @@ -17,7 +16,7 @@ import (
"github.com/ipld/go-car/v2/internal/store"
)

var _ blockstore.Blockstore = (*ReadWrite)(nil)
var _ Blockstore = (*ReadWrite)(nil)

var (
errFinalized = fmt.Errorf("cannot write in a carv2 blockstore after finalize")
Expand Down
2 changes: 1 addition & 1 deletion v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.19
require (
github.com/ipfs/go-block-format v0.1.2
github.com/ipfs/go-cid v0.4.1
github.com/ipfs/go-ipfs-blockstore v1.3.0
github.com/ipfs/go-ipld-cbor v0.0.6
github.com/ipfs/go-ipld-format v0.4.0
github.com/ipfs/go-merkledag v0.10.0
Expand Down Expand Up @@ -33,6 +32,7 @@ require (
github.com/ipfs/go-bitfield v1.1.0 // indirect
github.com/ipfs/go-blockservice v0.5.0 // indirect
github.com/ipfs/go-datastore v0.6.0 // indirect
github.com/ipfs/go-ipfs-blockstore v1.3.0 // indirect
github.com/ipfs/go-ipfs-chunker v0.0.5 // indirect
github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect
github.com/ipfs/go-ipfs-exchange-interface v0.2.0 // indirect
Expand Down

0 comments on commit 3f39582

Please sign in to comment.