diff --git a/accesscontroller/ipfs/accesscontroller_ipfs.go b/accesscontroller/ipfs/accesscontroller_ipfs.go index 447d541..9caedcd 100644 --- a/accesscontroller/ipfs/accesscontroller_ipfs.go +++ b/accesscontroller/ipfs/accesscontroller_ipfs.go @@ -14,7 +14,7 @@ import ( "berty.tech/go-orbit-db/iface" cid "github.com/ipfs/go-cid" cbornode "github.com/ipfs/go-ipld-cbor" - coreapi "github.com/ipfs/interface-go-ipfs-core" + coreiface "github.com/ipfs/kubo/core/coreiface" "github.com/polydawn/refmt/obj/atlas" "go.uber.org/zap" ) @@ -24,7 +24,7 @@ type cborWriteAccess struct { } type ipfsAccessController struct { - ipfs coreapi.CoreAPI + ipfs coreiface.CoreAPI writeAccess []string muWriteAccess sync.RWMutex logger *zap.Logger diff --git a/accesscontroller/manifest.go b/accesscontroller/manifest.go index bb24daf..5284d38 100644 --- a/accesscontroller/manifest.go +++ b/accesscontroller/manifest.go @@ -9,7 +9,7 @@ import ( "berty.tech/go-ipfs-log/io" cid "github.com/ipfs/go-cid" cbornode "github.com/ipfs/go-ipld-cbor" - coreapi "github.com/ipfs/interface-go-ipfs-core" + coreiface "github.com/ipfs/kubo/core/coreiface" "github.com/polydawn/refmt/obj/atlas" "go.uber.org/zap" ) @@ -140,7 +140,7 @@ type ManifestParams interface { } // CreateManifest Creates a new manifest and returns its CID -func CreateManifest(ctx context.Context, ipfs coreapi.CoreAPI, controllerType string, params ManifestParams) (cid.Cid, error) { +func CreateManifest(ctx context.Context, ipfs coreiface.CoreAPI, controllerType string, params ManifestParams) (cid.Cid, error) { if params.GetSkipManifest() { return params.GetAddress(), nil } @@ -157,7 +157,7 @@ func CreateManifest(ctx context.Context, ipfs coreapi.CoreAPI, controllerType st } // ResolveManifest Retrieves a manifest from its address -func ResolveManifest(ctx context.Context, ipfs coreapi.CoreAPI, manifestAddress string, params ManifestParams) (*Manifest, error) { +func ResolveManifest(ctx context.Context, ipfs coreiface.CoreAPI, manifestAddress string, params ManifestParams) (*Manifest, error) { if params.GetSkipManifest() { if params.GetType() == "" { return nil, fmt.Errorf("no manifest, access-controller type required") diff --git a/baseorbitdb/orbitdb.go b/baseorbitdb/orbitdb.go index 5461242..a74e15b 100644 --- a/baseorbitdb/orbitdb.go +++ b/baseorbitdb/orbitdb.go @@ -26,7 +26,7 @@ import ( datastore "github.com/ipfs/go-datastore" leveldb "github.com/ipfs/go-ds-leveldb" cbornode "github.com/ipfs/go-ipld-cbor" - coreapi "github.com/ipfs/interface-go-ipfs-core" + coreiface "github.com/ipfs/kubo/core/coreiface" "github.com/libp2p/go-libp2p/core/event" peer "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/p2p/host/eventbus" @@ -98,7 +98,7 @@ type orbitDB struct { cancel context.CancelFunc storeTypes map[string]iface.StoreConstructor accessControllerTypes map[string]iface.AccessControllerConstructor - ipfs coreapi.CoreAPI + ipfs coreiface.CoreAPI identity *idp.Identity id peer.ID pubsub iface.PubSubInterface @@ -136,7 +136,7 @@ func (o *orbitDB) Tracer() trace.Tracer { return o.tracer } -func (o *orbitDB) IPFS() coreapi.CoreAPI { +func (o *orbitDB) IPFS() coreiface.CoreAPI { o.muIPFS.RLock() defer o.muIPFS.RUnlock() @@ -316,7 +316,7 @@ func (o *orbitDB) getStoreConstructor(s string) (iface.StoreConstructor, bool) { return constructor, ok } -func newOrbitDB(ctx context.Context, is coreapi.CoreAPI, identity *idp.Identity, options *NewOrbitDBOptions) (BaseOrbitDB, error) { +func newOrbitDB(ctx context.Context, is coreiface.CoreAPI, identity *idp.Identity, options *NewOrbitDBOptions) (BaseOrbitDB, error) { if is == nil { return nil, fmt.Errorf("ipfs is a required argument") } @@ -408,7 +408,7 @@ func newOrbitDB(ctx context.Context, is coreapi.CoreAPI, identity *idp.Identity, } // NewOrbitDB Creates a new OrbitDB instance -func NewOrbitDB(ctx context.Context, ipfs coreapi.CoreAPI, options *NewOrbitDBOptions) (BaseOrbitDB, error) { +func NewOrbitDB(ctx context.Context, ipfs coreiface.CoreAPI, options *NewOrbitDBOptions) (BaseOrbitDB, error) { if ipfs == nil { return nil, fmt.Errorf("ipfs is a required argument") } @@ -571,10 +571,10 @@ func (o *orbitDB) Open(ctx context.Context, dbAddress string, options *CreateDBO return nil, fmt.Errorf("'options.Create' set to 'false'. If you want to create a database, set 'options.Create' to 'true'") } else if *options.Create && (options.StoreType == nil || *options.StoreType == "") { return nil, fmt.Errorf("database type not provided! Provide a type with 'options.StoreType' (%s)", strings.Join(o.storeTypesNames(), "|")) - } else { - options.Overwrite = boolPtr(true) - return o.Create(ctx, dbAddress, *options.StoreType, options) } + + options.Overwrite = boolPtr(true) + return o.Create(ctx, dbAddress, *options.StoreType, options) } parsedDBAddress, err := address.Parse(dbAddress) diff --git a/go.mod b/go.mod index a63d24d..5ce5169 100644 --- a/go.mod +++ b/go.mod @@ -4,12 +4,12 @@ go 1.21 require ( berty.tech/go-ipfs-log v1.10.2 + github.com/ipfs/boxo v0.18.0 github.com/ipfs/go-cid v0.4.1 github.com/ipfs/go-datastore v0.6.0 github.com/ipfs/go-ds-leveldb v0.5.0 github.com/ipfs/go-ipld-cbor v0.1.0 github.com/ipfs/go-libipfs v0.6.2 - github.com/ipfs/interface-go-ipfs-core v0.11.1 github.com/ipfs/kubo v0.27.0 github.com/libp2p/go-libp2p v0.33.0 github.com/libp2p/go-libp2p-pubsub v0.10.0 @@ -74,20 +74,16 @@ require ( github.com/ipfs-shipyard/nopfs v0.0.12 // indirect github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c // indirect github.com/ipfs/bbloom v0.0.4 // indirect - github.com/ipfs/boxo v0.18.0 // indirect github.com/ipfs/go-bitfield v1.1.0 // indirect github.com/ipfs/go-block-format v0.2.0 // indirect - github.com/ipfs/go-blockservice v0.5.0 // indirect github.com/ipfs/go-cidutil v0.1.0 // indirect github.com/ipfs/go-ds-badger v0.3.0 // indirect github.com/ipfs/go-ds-flatfs v0.5.1 // indirect github.com/ipfs/go-ds-measure v0.2.0 // indirect github.com/ipfs/go-fs-lock v0.0.7 // indirect - github.com/ipfs/go-ipfs-blockstore v1.3.0 // indirect github.com/ipfs/go-ipfs-cmds v0.10.0 // indirect github.com/ipfs/go-ipfs-delay v0.0.1 // indirect github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect - github.com/ipfs/go-ipfs-exchange-interface v0.2.0 // indirect github.com/ipfs/go-ipfs-pq v0.0.3 // indirect github.com/ipfs/go-ipfs-redirects-file v0.1.1 // indirect github.com/ipfs/go-ipfs-util v0.0.3 // indirect @@ -96,12 +92,9 @@ require ( github.com/ipfs/go-ipld-legacy v0.2.1 // indirect github.com/ipfs/go-log v1.0.5 // indirect github.com/ipfs/go-log/v2 v2.5.1 // indirect - github.com/ipfs/go-merkledag v0.11.0 // indirect github.com/ipfs/go-metrics-interface v0.0.1 // indirect - github.com/ipfs/go-path v0.3.1 // indirect github.com/ipfs/go-peertaskqueue v0.8.1 // indirect github.com/ipfs/go-unixfsnode v1.9.0 // indirect - github.com/ipfs/go-verifcid v0.0.2 // indirect github.com/ipld/go-car/v2 v2.13.1 // indirect github.com/ipld/go-codec-dagpb v1.6.0 // indirect github.com/ipld/go-ipld-prime v0.21.0 // indirect @@ -197,7 +190,6 @@ require ( go.opentelemetry.io/otel/metric v1.22.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect - go.uber.org/atomic v1.11.0 // indirect go.uber.org/dig v1.17.1 // indirect go.uber.org/fx v1.20.1 // indirect go.uber.org/mock v0.4.0 // indirect diff --git a/go.sum b/go.sum index f00959b..54d21fc 100644 --- a/go.sum +++ b/go.sum @@ -277,8 +277,6 @@ github.com/ipfs/boxo v0.18.0 h1:MOL9/AgoV3e7jlVMInicaSdbgralfqSsbkc31dZ9tmw= github.com/ipfs/boxo v0.18.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA= github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU= -github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ= -github.com/ipfs/go-bitswap v0.11.0/go.mod h1:05aE8H3XOU+LXpTedeAS0OZpcO1WFsj5niYQH9a1Tmk= github.com/ipfs/go-block-format v0.0.3/go.mod h1:4LmD4ZUw0mhO+JSKdpWwrzATiEfM7WWgQ8H5l6P8MVk= github.com/ipfs/go-block-format v0.2.0 h1:ZqrkxBA2ICbDRbK8KJs/u0O3dlp6gmAuuXUJNiW1Ycs= github.com/ipfs/go-block-format v0.2.0/go.mod h1:+jpL11nFx5A/SPpsoBn6Bzkra/zaArfSmsknbPMYgzM= @@ -333,8 +331,6 @@ github.com/ipfs/go-ipfs-pq v0.0.3 h1:YpoHVJB+jzK15mr/xsWC574tyDLkezVrDNeaalQBsTE github.com/ipfs/go-ipfs-pq v0.0.3/go.mod h1:btNw5hsHBpRcSSgZtiNm/SLj5gYIZ18AKtv3kERkRb4= github.com/ipfs/go-ipfs-redirects-file v0.1.1 h1:Io++k0Vf/wK+tfnhEh63Yte1oQK5VGT2hIEYpD0Rzx8= github.com/ipfs/go-ipfs-redirects-file v0.1.1/go.mod h1:tAwRjCV0RjLTjH8DR/AU7VYvfQECg+lpUy2Mdzv7gyk= -github.com/ipfs/go-ipfs-routing v0.3.0 h1:9W/W3N+g+y4ZDeffSgqhgo7BsBSJwPMcyssET9OWevc= -github.com/ipfs/go-ipfs-routing v0.3.0/go.mod h1:dKqtTFIql7e1zYsEuWLyuOU+E0WJWW8JjbTPLParDWo= github.com/ipfs/go-ipfs-util v0.0.1/go.mod h1:spsl5z8KUnrve+73pOhSVZND1SIxPW5RyBCNzQxlJBc= github.com/ipfs/go-ipfs-util v0.0.2/go.mod h1:CbPtkWJzjLdEcezDns2XYaehFVNXG9zrdrtMecczcsQ= github.com/ipfs/go-ipfs-util v0.0.3 h1:2RFdGez6bu2ZlZdI+rWfIdbQb1KudQp3VGwPtdNCmE0= @@ -363,8 +359,6 @@ github.com/ipfs/go-merkledag v0.11.0 h1:DgzwK5hprESOzS4O1t/wi6JDpyVQdvm9Bs59N/jq github.com/ipfs/go-merkledag v0.11.0/go.mod h1:Q4f/1ezvBiJV0YCIXvt51W/9/kqJGH4I1LsA7+djsM4= github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg= github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY= -github.com/ipfs/go-path v0.3.1 h1:wkeaCWE/NTuuPGlEkLTsED5UkzfKYZpxaFFPgk8ZVLE= -github.com/ipfs/go-path v0.3.1/go.mod h1:eNLsxJEEMxn/CDzUJ6wuNl+6No6tEUhOZcPKsZsYX0E= github.com/ipfs/go-peertaskqueue v0.8.1 h1:YhxAs1+wxb5jk7RvS0LHdyiILpNmRIRnZVztekOF0pg= github.com/ipfs/go-peertaskqueue v0.8.1/go.mod h1:Oxxd3eaK279FxeydSPPVGHzbwVeHjatZ2GA8XD+KbPU= github.com/ipfs/go-unixfs v0.4.5 h1:wj8JhxvV1G6CD7swACwSKYa+NgtdWC1RUit+gFnymDU= @@ -373,8 +367,6 @@ github.com/ipfs/go-unixfsnode v1.9.0 h1:ubEhQhr22sPAKO2DNsyVBW7YB/zA8Zkif25aBvz8 github.com/ipfs/go-unixfsnode v1.9.0/go.mod h1:HxRu9HYHOjK6HUqFBAi++7DVoWAHn0o4v/nZ/VA+0g8= github.com/ipfs/go-verifcid v0.0.2 h1:XPnUv0XmdH+ZIhLGKg6U2vaPaRDXb9urMyNVCE7uvTs= github.com/ipfs/go-verifcid v0.0.2/go.mod h1:40cD9x1y4OWnFXbLNJYRe7MpNvWlMn3LZAG5Wb4xnPU= -github.com/ipfs/interface-go-ipfs-core v0.11.1 h1:xVW8DKzd230h8bPv+oC2fBjW4PtDGqGtvpX64/aBe48= -github.com/ipfs/interface-go-ipfs-core v0.11.1/go.mod h1:xmnoccUXY7N/Q8AIx0vFqgW926/FAZ8+do/1NTEHKsU= github.com/ipfs/kubo v0.27.0 h1:rVWKI9VGYt8Eyr/4vflUbT6OrOgOWG0ddHeEAajKClA= github.com/ipfs/kubo v0.27.0/go.mod h1:7HMQUnD+S1q9P3G7iV3VfwHzukJ/PeUm4geYYDC+hx0= github.com/ipld/go-car/v2 v2.13.1 h1:KnlrKvEPEzr5IZHKTXLAEub+tPrzeAFQVRlSQvuxBO4= diff --git a/iface/interface.go b/iface/interface.go index f74654b..9627efc 100644 --- a/iface/interface.go +++ b/iface/interface.go @@ -16,7 +16,7 @@ import ( "berty.tech/go-orbit-db/stores/replicator" cid "github.com/ipfs/go-cid" datastore "github.com/ipfs/go-datastore" - coreapi "github.com/ipfs/interface-go-ipfs-core" + coreiface "github.com/ipfs/kubo/core/coreiface" "github.com/libp2p/go-libp2p/core/event" peer "github.com/libp2p/go-libp2p/core/peer" "go.opentelemetry.io/otel/trace" @@ -75,7 +75,7 @@ type DetermineAddressOptions struct { // BaseOrbitDB Provides the main OrbitDB interface used to open and create stores type BaseOrbitDB interface { // IPFS Returns the instance of the IPFS API used by the current DB - IPFS() coreapi.CoreAPI + IPFS() coreiface.CoreAPI // Identity Returns the identity used by the current DB Identity() *identityprovider.Identity @@ -220,7 +220,7 @@ type Store interface { OpLog() ipfslog.Log // IPFS Returns the IPFS instance for the store - IPFS() coreapi.CoreAPI + IPFS() coreiface.CoreAPI // DBName Returns the store name as a string DBName() string @@ -378,7 +378,7 @@ type DirectChannelEmitter interface { type DirectChannelFactory func(ctx context.Context, emitter DirectChannelEmitter, opts *DirectChannelOptions) (DirectChannel, error) // StoreConstructor Defines the expected constructor for a custom store -type StoreConstructor func(coreapi.CoreAPI, *identityprovider.Identity, address.Address, *NewStoreOptions) (Store, error) +type StoreConstructor func(coreiface.CoreAPI, *identityprovider.Identity, address.Address, *NewStoreOptions) (Store, error) // IndexConstructor Defines the expected constructor for a custom index type IndexConstructor func(publicKey []byte) StoreIndex diff --git a/orbitdb.go b/orbitdb.go index 4ef17ce..6cde441 100644 --- a/orbitdb.go +++ b/orbitdb.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - coreapi "github.com/ipfs/interface-go-ipfs-core" + coreiface "github.com/ipfs/kubo/core/coreiface" "berty.tech/go-orbit-db/accesscontroller/ipfs" "berty.tech/go-orbit-db/accesscontroller/orbitdb" @@ -63,7 +63,7 @@ type DetermineAddressOptions = iface.DetermineAddressOptions type NewOrbitDBOptions = baseorbitdb.NewOrbitDBOptions // NewOrbitDB Creates a new OrbitDB instance with default access controllers and store types -func NewOrbitDB(ctx context.Context, i coreapi.CoreAPI, options *NewOrbitDBOptions) (iface.OrbitDB, error) { +func NewOrbitDB(ctx context.Context, i coreiface.CoreAPI, options *NewOrbitDBOptions) (iface.OrbitDB, error) { odb, err := baseorbitdb.NewOrbitDB(ctx, i, options) if err != nil { diff --git a/pubsub/oneonone/channel.go b/pubsub/oneonone/channel.go index 1918731..075febe 100644 --- a/pubsub/oneonone/channel.go +++ b/pubsub/oneonone/channel.go @@ -8,8 +8,8 @@ import ( "sync" "time" - coreapi "github.com/ipfs/interface-go-ipfs-core" - "github.com/ipfs/interface-go-ipfs-core/options" + coreiface "github.com/ipfs/kubo/core/coreiface" + "github.com/ipfs/kubo/core/coreiface/options" peer "github.com/libp2p/go-libp2p/core/peer" "go.uber.org/zap" @@ -26,7 +26,7 @@ type channel struct { ctx context.Context cancel context.CancelFunc id string - sub coreapi.PubSubSubscription + sub coreiface.PubSubSubscription } type channels struct { @@ -37,7 +37,7 @@ type channels struct { emitter iface.DirectChannelEmitter ctx context.Context cancel context.CancelFunc - ipfs coreapi.CoreAPI + ipfs coreiface.CoreAPI logger *zap.Logger } @@ -133,7 +133,7 @@ func (c *channels) getChannelID(p peer.ID) string { return fmt.Sprintf("/%s/%s", PROTOCOL, strings.Join(channelIDPeers, "/")) } -func (c *channels) monitorTopic(ctx context.Context, sub coreapi.PubSubSubscription, p peer.ID) { +func (c *channels) monitorTopic(ctx context.Context, sub coreiface.PubSubSubscription, p peer.ID) { for { msg, err := sub.Next(ctx) switch err { @@ -173,7 +173,7 @@ func (c *channels) Close() error { } // NewChannel Creates a new pubsub topic for communication between two peers -func NewChannelFactory(ipfs coreapi.CoreAPI) iface.DirectChannelFactory { +func NewChannelFactory(ipfs coreiface.CoreAPI) iface.DirectChannelFactory { return func(ctx context.Context, emitter iface.DirectChannelEmitter, opts *iface.DirectChannelOptions) (iface.DirectChannel, error) { ctx, cancel := context.WithCancel(ctx) diff --git a/pubsub/pubsubcoreapi/pubsub.go b/pubsub/pubsubcoreapi/pubsub.go index 5ec5f0a..341fcfc 100644 --- a/pubsub/pubsubcoreapi/pubsub.go +++ b/pubsub/pubsubcoreapi/pubsub.go @@ -5,8 +5,8 @@ import ( "sync" "time" - coreapi "github.com/ipfs/interface-go-ipfs-core" - options "github.com/ipfs/interface-go-ipfs-core/options" + coreiface "github.com/ipfs/kubo/core/coreiface" + "github.com/ipfs/kubo/core/coreiface/options" "github.com/libp2p/go-libp2p/core/peer" "go.opentelemetry.io/otel/trace" "go.uber.org/zap" @@ -141,7 +141,7 @@ func (p *psTopic) Topic() string { } type coreAPIPubSub struct { - api coreapi.CoreAPI + api coreiface.CoreAPI logger *zap.Logger id peer.ID pollInterval time.Duration @@ -166,7 +166,7 @@ func (c *coreAPIPubSub) TopicSubscribe(_ context.Context, topic string) (iface.P return c.topics[topic], nil } -func NewPubSub(api coreapi.CoreAPI, id peer.ID, pollInterval time.Duration, logger *zap.Logger, tracer trace.Tracer) iface.PubSubInterface { +func NewPubSub(api coreiface.CoreAPI, id peer.ID, pollInterval time.Duration, logger *zap.Logger, tracer trace.Tracer) iface.PubSubInterface { if logger == nil { logger = zap.NewNop() } diff --git a/stores/basestore/base_store.go b/stores/basestore/base_store.go index 45880b8..419fce6 100644 --- a/stores/basestore/base_store.go +++ b/stores/basestore/base_store.go @@ -23,11 +23,11 @@ import ( "berty.tech/go-orbit-db/stores" "berty.tech/go-orbit-db/stores/operation" "berty.tech/go-orbit-db/stores/replicator" + "github.com/ipfs/boxo/path" cid "github.com/ipfs/go-cid" datastore "github.com/ipfs/go-datastore" files "github.com/ipfs/go-libipfs/files" - coreapi "github.com/ipfs/interface-go-ipfs-core" - "github.com/ipfs/interface-go-ipfs-core/path" + coreiface "github.com/ipfs/kubo/core/coreiface" "github.com/libp2p/go-libp2p/core/event" "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/p2p/host/eventbus" @@ -54,7 +54,7 @@ type BaseStore struct { identity *identityprovider.Identity address address.Address dbName string - ipfs coreapi.CoreAPI + ipfs coreiface.CoreAPI cache datastore.Datastore access accesscontroller.Interface oplog ipfslog.Log @@ -89,7 +89,7 @@ func (b *BaseStore) DBName() string { return b.dbName } -func (b *BaseStore) IPFS() coreapi.CoreAPI { +func (b *BaseStore) IPFS() coreiface.CoreAPI { return b.ipfs } @@ -136,7 +136,7 @@ func (b *BaseStore) EventBus() event.Bus { } // InitBaseStore Initializes the store base -func (b *BaseStore) InitBaseStore(ipfs coreapi.CoreAPI, identity *identityprovider.Identity, addr address.Address, options *iface.NewStoreOptions) error { +func (b *BaseStore) InitBaseStore(ipfs coreiface.CoreAPI, identity *identityprovider.Identity, addr address.Address, options *iface.NewStoreOptions) error { var err error b.ctx, b.cancel = context.WithCancel(context.Background()) @@ -719,7 +719,12 @@ func (b *BaseStore) LoadFromSnapshot(ctx context.Context) error { b.Logger().Debug("loading snapshot from path", zap.String("snapshot", string(snapshot))) - resNode, err := b.IPFS().Unixfs().Get(ctx, path.New(string(snapshot))) + path, err := path.NewPath(string(snapshot)) + if err != nil { + return fmt.Errorf("unable to convert string to path: %w", err) + } + + resNode, err := b.IPFS().Unixfs().Get(ctx, path) if err != nil { return fmt.Errorf("unable to get snapshot from ipfs: %w", err) } diff --git a/stores/basestore/utils.go b/stores/basestore/utils.go index f7948ab..73c540e 100644 --- a/stores/basestore/utils.go +++ b/stores/basestore/utils.go @@ -73,7 +73,7 @@ func SaveSnapshot(ctx context.Context, b iface.Store) (cid.Cid, error) { return cid.Cid{}, fmt.Errorf("unable to save log data on store: %w", err) } - err = b.Cache().Put(ctx, datastore.NewKey("snapshot"), []byte(snapshotPath.Cid().String())) + err = b.Cache().Put(ctx, datastore.NewKey("snapshot"), []byte(snapshotPath.String())) if err != nil { return cid.Cid{}, fmt.Errorf("unable to add snapshot data to cache: %w", err) } @@ -88,5 +88,5 @@ func SaveSnapshot(ctx context.Context, b iface.Store) (cid.Cid, error) { return cid.Cid{}, fmt.Errorf("unable to add unfinished data to cache: %w", err) } - return snapshotPath.Cid(), nil + return snapshotPath.RootCid(), nil } diff --git a/stores/documentstore/document.go b/stores/documentstore/document.go index 449a33a..ac9f471 100644 --- a/stores/documentstore/document.go +++ b/stores/documentstore/document.go @@ -12,7 +12,7 @@ import ( "berty.tech/go-orbit-db/stores/basestore" "berty.tech/go-orbit-db/stores/operation" - coreapi "github.com/ipfs/interface-go-ipfs-core" + coreiface "github.com/ipfs/kubo/core/coreiface" ) type orbitDBDocumentStore struct { @@ -242,7 +242,7 @@ func DefaultStoreOptsForMap(keyField string) *iface.CreateDocumentDBOptions { } // NewOrbitDBDocumentStore Instantiates a new DocumentStore -func NewOrbitDBDocumentStore(ipfs coreapi.CoreAPI, identity *identityprovider.Identity, addr address.Address, options *iface.NewStoreOptions) (iface.Store, error) { +func NewOrbitDBDocumentStore(ipfs coreiface.CoreAPI, identity *identityprovider.Identity, addr address.Address, options *iface.NewStoreOptions) (iface.Store, error) { if options.StoreSpecificOpts == nil { options.StoreSpecificOpts = DefaultStoreOptsForMap("_id") } diff --git a/stores/eventlogstore/log.go b/stores/eventlogstore/log.go index 3f42a98..6522179 100644 --- a/stores/eventlogstore/log.go +++ b/stores/eventlogstore/log.go @@ -11,7 +11,7 @@ import ( "berty.tech/go-orbit-db/stores/basestore" "berty.tech/go-orbit-db/stores/operation" cid "github.com/ipfs/go-cid" - coreapi "github.com/ipfs/interface-go-ipfs-core" + coreiface "github.com/ipfs/kubo/core/coreiface" ) type orbitDBEventLogStore struct { @@ -201,7 +201,7 @@ func (o *orbitDBEventLogStore) Type() string { } // NewOrbitDBEventLogStore Instantiates a new EventLogStore -func NewOrbitDBEventLogStore(ipfs coreapi.CoreAPI, identity *identityprovider.Identity, addr address.Address, options *iface.NewStoreOptions) (i iface.Store, e error) { +func NewOrbitDBEventLogStore(ipfs coreiface.CoreAPI, identity *identityprovider.Identity, addr address.Address, options *iface.NewStoreOptions) (i iface.Store, e error) { store := &orbitDBEventLogStore{} options.Index = NewEventIndex diff --git a/stores/kvstore/keyvalue.go b/stores/kvstore/keyvalue.go index 8fa2469..4c9ab3c 100644 --- a/stores/kvstore/keyvalue.go +++ b/stores/kvstore/keyvalue.go @@ -5,7 +5,7 @@ import ( "fmt" "berty.tech/go-ipfs-log/identityprovider" - coreapi "github.com/ipfs/interface-go-ipfs-core" + coreiface "github.com/ipfs/kubo/core/coreiface" "berty.tech/go-orbit-db/address" "berty.tech/go-orbit-db/iface" @@ -85,7 +85,7 @@ func (o *orbitDBKeyValue) Type() string { } // NewOrbitDBKeyValue Instantiates a new KeyValueStore -func NewOrbitDBKeyValue(ipfs coreapi.CoreAPI, identity *identityprovider.Identity, addr address.Address, options *iface.NewStoreOptions) (i iface.Store, e error) { +func NewOrbitDBKeyValue(ipfs coreiface.CoreAPI, identity *identityprovider.Identity, addr address.Address, options *iface.NewStoreOptions) (i iface.Store, e error) { store := &orbitDBKeyValue{} options.Index = NewKVIndex diff --git a/stores/replicator/interface.go b/stores/replicator/interface.go index ea4456b..9accd78 100644 --- a/stores/replicator/interface.go +++ b/stores/replicator/interface.go @@ -7,14 +7,14 @@ import ( "berty.tech/go-ipfs-log/identityprovider" "berty.tech/go-orbit-db/accesscontroller" cid "github.com/ipfs/go-cid" - coreapi "github.com/ipfs/interface-go-ipfs-core" + coreiface "github.com/ipfs/kubo/core/coreiface" "github.com/libp2p/go-libp2p/core/event" ) // storeInterface An interface used to avoid import cycles type storeInterface interface { OpLog() ipfslog.Log - IPFS() coreapi.CoreAPI + IPFS() coreiface.CoreAPI Identity() *identityprovider.Identity AccessController() accesscontroller.Interface SortFn() ipfslog.SortFn diff --git a/tests/testing_test.go b/tests/testing_test.go index b80a39d..c12f4e1 100644 --- a/tests/testing_test.go +++ b/tests/testing_test.go @@ -13,10 +13,10 @@ import ( ds "github.com/ipfs/go-datastore" dsync "github.com/ipfs/go-datastore/sync" - iface "github.com/ipfs/interface-go-ipfs-core" cfg "github.com/ipfs/kubo/config" ipfsCore "github.com/ipfs/kubo/core" "github.com/ipfs/kubo/core/coreapi" + coreiface "github.com/ipfs/kubo/core/coreiface" mock "github.com/ipfs/kubo/core/mock" "github.com/ipfs/kubo/repo" mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" @@ -39,7 +39,7 @@ func testingRepo(ctx context.Context, t *testing.T) repo.Repo { c.Pubsub.Enabled = cfg.True c.Bootstrap = []string{} c.Addresses.Swarm = []string{"/ip4/127.0.0.1/tcp/4001", "/ip4/127.0.0.1/udp/4001/quic"} - c.Identity.PeerID = pid.Pretty() + c.Identity.PeerID = pid.String() c.Identity.PrivKey = base64.StdEncoding.EncodeToString(privkeyb) c.Swarm.ResourceMgr.Enabled = cfg.False // we don't need ressources manager for test @@ -49,13 +49,13 @@ func testingRepo(ctx context.Context, t *testing.T) repo.Repo { } } -func testingIPFSAPIs(ctx context.Context, t *testing.T, count int) ([]iface.CoreAPI, func()) { +func testingIPFSAPIs(ctx context.Context, t *testing.T, count int) ([]coreiface.CoreAPI, func()) { t.Helper() mn := testingMockNet(t) defer mn.Close() - coreAPIs := make([]iface.CoreAPI, count) + coreAPIs := make([]coreiface.CoreAPI, count) cleans := make([]func(), count) for i := 0; i < count; i++ { @@ -72,10 +72,10 @@ func testingIPFSAPIs(ctx context.Context, t *testing.T, count int) ([]iface.Core } } -func testingIPFSAPIsNonMocked(ctx context.Context, t *testing.T, count int) ([]iface.CoreAPI, func()) { +func testingIPFSAPIsNonMocked(ctx context.Context, t *testing.T, count int) ([]coreiface.CoreAPI, func()) { t.Helper() - coreAPIs := make([]iface.CoreAPI, count) + coreAPIs := make([]coreiface.CoreAPI, count) cleans := make([]func(), count) for i := 0; i < count; i++ { @@ -151,7 +151,7 @@ func testingNonMockedIPFSNode(ctx context.Context, t *testing.T) (*ipfsCore.Ipfs return core, cleanup } -func testingCoreAPI(t *testing.T, core *ipfsCore.IpfsNode) iface.CoreAPI { +func testingCoreAPI(t *testing.T, core *ipfsCore.IpfsNode) coreiface.CoreAPI { t.Helper() api, err := coreapi.NewCoreAPI(core) diff --git a/utils/create_db_manifest.go b/utils/create_db_manifest.go index 4fe076d..cf7b96a 100644 --- a/utils/create_db_manifest.go +++ b/utils/create_db_manifest.go @@ -8,7 +8,7 @@ import ( "berty.tech/go-ipfs-log/io" cid "github.com/ipfs/go-cid" cbornode "github.com/ipfs/go-ipld-cbor" - coreapi "github.com/ipfs/interface-go-ipfs-core" + coreiface "github.com/ipfs/kubo/core/coreiface" "github.com/polydawn/refmt/obj/atlas" ) @@ -20,7 +20,7 @@ type Manifest struct { } // CreateDBManifest creates a new database manifest and saves it on IPFS -func CreateDBManifest(ctx context.Context, ipfs coreapi.CoreAPI, name string, dbType string, accessControllerAddress string) (cid.Cid, error) { +func CreateDBManifest(ctx context.Context, ipfs coreiface.CoreAPI, name string, dbType string, accessControllerAddress string) (cid.Cid, error) { manifest := &Manifest{ Name: name, Type: dbType,