2020-04-29 23:51:55 +00:00
|
|
|
package modules
|
|
|
|
|
|
|
|
import (
|
|
|
|
"go.uber.org/fx"
|
|
|
|
"golang.org/x/xerrors"
|
|
|
|
|
|
|
|
"github.com/ipfs/go-filestore"
|
|
|
|
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/lib/bufbstore"
|
|
|
|
"github.com/filecoin-project/lotus/lib/ipfsbstore"
|
|
|
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
|
|
|
"github.com/filecoin-project/lotus/node/modules/helpers"
|
|
|
|
)
|
|
|
|
|
|
|
|
func IpfsClientBlockstore(mctx helpers.MetricsCtx, lc fx.Lifecycle, fstore dtypes.ClientFilestore) (dtypes.ClientBlockstore, error) {
|
|
|
|
ipfsbs, err := ipfsbstore.NewIpfsBstore(helpers.LifecycleCtx(mctx, lc))
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("constructing ipfs blockstore: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return bufbstore.NewTieredBstore(
|
2020-04-30 10:51:19 +00:00
|
|
|
ipfsbs,
|
|
|
|
blockstore.NewIdStore((*filestore.Filestore)(fstore)),
|
|
|
|
), nil
|
|
|
|
}
|