6c01310728
This migrates everything except the `go-car` librairy: https://github.com/ipfs/boxo/issues/218#issuecomment-1529922103 I didn't migrated everything in the previous release because all the boxo code wasn't compatible with the go-ipld-prime one due to a an in flight (/ aftermath) revert of github.com/ipfs/go-block-format. go-block-format has been unmigrated since slight bellow absolutely everything depends on it that would have required everything to be moved on boxo or everything to optin into using boxo which were all deal breakers for different groups. This worked fine because lotus's codebase could live hapely on the first multirepo setup however boost is now trying to use boxo's code with lotus's (still on multirepo) setup: https://filecoinproject.slack.com/archives/C03AQ3QAUG1/p1685022344779649 The alternative would be for boost to write shim types which just forward calls and return with the different interface definitions. Btw why is that an issue in the first place is because unlike what go's duck typing model suggest interfaces are not transparent https://github.com/golang/go/issues/58112, interfaces are strongly typed but they have implicit narrowing. The issue is if you return an interface from an interface Go does not have a function definition to insert the implicit conversion thus instead the type checker complains you are not returning the right type. Stubbing types were reverted https://github.com/ipfs/boxo/issues/218#issuecomment-1478650351 Last time I only migrated `go-bitswap` to `boxo/bitswap` because of the security issues and because we never had the interface return an interface problem (we had concrete wrappers where the implicit conversion took place).
51 lines
2.2 KiB
Go
51 lines
2.2 KiB
Go
package modules
|
|
|
|
import (
|
|
bstore "github.com/ipfs/boxo/blockstore"
|
|
"github.com/multiformats/go-multiaddr"
|
|
"go.uber.org/fx"
|
|
"golang.org/x/xerrors"
|
|
|
|
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
|
|
|
"github.com/filecoin-project/lotus/blockstore"
|
|
"github.com/filecoin-project/lotus/markets/retrievaladapter"
|
|
"github.com/filecoin-project/lotus/markets/storageadapter"
|
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
|
"github.com/filecoin-project/lotus/node/modules/helpers"
|
|
)
|
|
|
|
func IpfsStorageBlockstoreAccessor(ipfsBlockstore dtypes.ClientBlockstore) storagemarket.BlockstoreAccessor {
|
|
return storageadapter.NewFixedBlockstoreAccessor(bstore.Blockstore(ipfsBlockstore))
|
|
}
|
|
|
|
func IpfsRetrievalBlockstoreAccessor(ipfsBlockstore dtypes.ClientBlockstore) retrievalmarket.BlockstoreAccessor {
|
|
return retrievaladapter.NewFixedBlockstoreAccessor(bstore.Blockstore(ipfsBlockstore))
|
|
}
|
|
|
|
// IpfsClientBlockstore returns a ClientBlockstore implementation backed by an IPFS node.
|
|
// If ipfsMaddr is empty, a local IPFS node is assumed considering IPFS_PATH configuration.
|
|
// If ipfsMaddr is not empty, it will connect to the remote IPFS node with the provided multiaddress.
|
|
// The flag useForRetrieval indicates if the IPFS node will also be used for storing retrieving deals.
|
|
func IpfsClientBlockstore(ipfsMaddr string, onlineMode bool) func(helpers.MetricsCtx, fx.Lifecycle, dtypes.ClientImportMgr) (dtypes.ClientBlockstore, error) {
|
|
return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, localStore dtypes.ClientImportMgr) (dtypes.ClientBlockstore, error) {
|
|
var err error
|
|
var ipfsbs blockstore.BasicBlockstore
|
|
if ipfsMaddr != "" {
|
|
var ma multiaddr.Multiaddr
|
|
ma, err = multiaddr.NewMultiaddr(ipfsMaddr)
|
|
if err != nil {
|
|
return nil, xerrors.Errorf("parsing ipfs multiaddr: %w", err)
|
|
}
|
|
ipfsbs, err = blockstore.NewRemoteIPFSBlockstore(helpers.LifecycleCtx(mctx, lc), ma, onlineMode)
|
|
} else {
|
|
ipfsbs, err = blockstore.NewLocalIPFSBlockstore(helpers.LifecycleCtx(mctx, lc), onlineMode)
|
|
}
|
|
if err != nil {
|
|
return nil, xerrors.Errorf("constructing ipfs blockstore: %w", err)
|
|
}
|
|
return blockstore.WrapIDStore(ipfsbs), nil
|
|
}
|
|
}
|