Skip to content

Commit

Permalink
fix: code compatible with denpendencies upgrades
Browse files Browse the repository at this point in the history
Signed-off-by: D4ryl00 <[email protected]>
  • Loading branch information
D4ryl00 committed Apr 12, 2024
1 parent 0e443eb commit b71659a
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 71 deletions.
4 changes: 2 additions & 2 deletions accesscontroller/ipfs/accesscontroller_ipfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -24,7 +24,7 @@ type cborWriteAccess struct {
}

type ipfsAccessController struct {
ipfs coreapi.CoreAPI
ipfs coreiface.CoreAPI
writeAccess []string
muWriteAccess sync.RWMutex
logger *zap.Logger
Expand Down
6 changes: 3 additions & 3 deletions accesscontroller/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}
Expand All @@ -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")
Expand Down
16 changes: 8 additions & 8 deletions baseorbitdb/orbitdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 1 addition & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand All @@ -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=
Expand Down
8 changes: 4 additions & 4 deletions iface/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions orbitdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions pubsub/oneonone/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -26,7 +26,7 @@ type channel struct {
ctx context.Context
cancel context.CancelFunc
id string
sub coreapi.PubSubSubscription
sub coreiface.PubSubSubscription
}

type channels struct {
Expand All @@ -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
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions pubsub/pubsubcoreapi/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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()
}
Expand Down
17 changes: 11 additions & 6 deletions stores/basestore/base_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions stores/basestore/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
}
Loading

0 comments on commit b71659a

Please sign in to comment.