Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/blockstore nits #4813

Merged
merged 2 commits into from
Nov 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion documentation/en/architecture/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ FIXME: Maybe mention the `Batching` interface as the developer will stumble upon

FIXME: IPFS blocks vs Filecoin blocks ideally happens before this / here

The [`Blockstore` interface](`github.com/ipfs/go-ipfs-blockstore/blockstore.go`) structures the key-value pair
The [`Blockstore` interface](`github.com/filecoin-project/lotus/lib/blockstore.go`) structures the key-value pair
into the CID format for the key and the [`Block` interface](`github.com/ipfs/go-block-format/blocks.go`) for the value.
The `Block` value is just a raw string of bytes addressed by its hash, which is included in the CID key.

Expand Down
4 changes: 0 additions & 4 deletions lib/blockstore/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,8 @@ func NewBlockstore(dstore ds.Batching) blockstore.Blockstore {
// Alias so other packages don't have to import go-ipfs-blockstore
type Blockstore = blockstore.Blockstore
type Viewer = blockstore.Viewer
type GCBlockstore = blockstore.GCBlockstore
type CacheOpts = blockstore.CacheOpts
type GCLocker = blockstore.GCLocker

var NewGCLocker = blockstore.NewGCLocker
var NewGCBlockstore = blockstore.NewGCBlockstore
var ErrNotFound = blockstore.ErrNotFound

func DefaultCacheOpts() CacheOpts {
Expand Down
7 changes: 3 additions & 4 deletions lib/blockstore/memstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

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

// MemStore is a terminal blockstore that keeps blocks in memory.
Expand All @@ -24,15 +23,15 @@ func (m MemStore) Has(k cid.Cid) (bool, error) {
func (m MemStore) View(k cid.Cid, callback func([]byte) error) error {
b, ok := m[k]
if !ok {
return blockstore.ErrNotFound
return ErrNotFound
}
return callback(b.RawData())
}

func (m MemStore) Get(k cid.Cid) (blocks.Block, error) {
b, ok := m[k]
if !ok {
return nil, blockstore.ErrNotFound
return nil, ErrNotFound
}
return b, nil
}
Expand All @@ -41,7 +40,7 @@ func (m MemStore) Get(k cid.Cid) (blocks.Block, error) {
func (m MemStore) GetSize(k cid.Cid) (int, error) {
b, ok := m[k]
if !ok {
return 0, blockstore.ErrNotFound
return 0, ErrNotFound
}
return len(b.RawData()), nil
}
Expand Down
3 changes: 0 additions & 3 deletions node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import (
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
"github.com/filecoin-project/lotus/journal"
"github.com/filecoin-project/lotus/lib/blockstore"
"github.com/filecoin-project/lotus/lib/peermgr"
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
Expand Down Expand Up @@ -264,8 +263,6 @@ func Online() Option {
Override(new(api.WalletAPI), From(new(wallet.MultiWallet))),
Override(new(*messagesigner.MessageSigner), messagesigner.NewMessageSigner),

Override(new(dtypes.ChainGCLocker), blockstore.NewGCLocker),
Override(new(dtypes.ChainGCBlockstore), modules.ChainGCBlockstore),
Override(new(dtypes.ChainBitswap), modules.ChainBitswap),
Override(new(dtypes.ChainBlockService), modules.ChainBlockService),

Expand Down
6 changes: 1 addition & 5 deletions node/modules/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"github.com/filecoin-project/lotus/node/repo"
)

func ChainBitswap(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, rt routing.Routing, bs dtypes.ChainGCBlockstore) dtypes.ChainBitswap {
func ChainBitswap(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, rt routing.Routing, bs dtypes.ChainBlockstore) dtypes.ChainBitswap {
// prefix protocol for chain bitswap
// (so bitswap uses /chain/ipfs/bitswap/1.0.0 internally for chain sync stuff)
bitswapNetwork := network.NewFromIpfsHost(host, rt, network.Prefix("/chain"))
Expand Down Expand Up @@ -91,10 +91,6 @@ func ChainRawBlockstore(lc fx.Lifecycle, mctx helpers.MetricsCtx, r repo.LockedR
return cbs, nil
}

func ChainGCBlockstore(bs dtypes.ChainRawBlockstore, gcl dtypes.ChainGCLocker) dtypes.ChainGCBlockstore {
return blockstore.NewGCBlockstore(bs, gcl)
}

func ChainBlockService(bs dtypes.ChainRawBlockstore, rem dtypes.ChainBitswap) dtypes.ChainBlockService {
return blockservice.New(bs, rem)
}
Expand Down
2 changes: 0 additions & 2 deletions node/modules/dtypes/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ type MetadataDS datastore.Batching
type ChainRawBlockstore blockstore.Blockstore
type ChainBlockstore blockstore.Blockstore // optionally bitswap backed

type ChainGCLocker blockstore.GCLocker
type ChainGCBlockstore blockstore.GCBlockstore
type ChainBitswap exchange.Interface
type ChainBlockService bserv.BlockService

Expand Down
2 changes: 1 addition & 1 deletion node/repo/fsrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"sync"

"github.com/BurntSushi/toml"
"github.com/filecoin-project/lotus/lib/blockstore"
"github.com/ipfs/go-datastore"
fslock "github.com/ipfs/go-fs-lock"
blockstore "github.com/ipfs/go-ipfs-blockstore"
logging "github.com/ipfs/go-log/v2"
"github.com/mitchellh/go-homedir"
"github.com/multiformats/go-base32"
Expand Down
2 changes: 1 addition & 1 deletion node/repo/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package repo
import (
"errors"

"github.com/filecoin-project/lotus/lib/blockstore"
"github.com/ipfs/go-datastore"
blockstore "github.com/ipfs/go-ipfs-blockstore"
"github.com/multiformats/go-multiaddr"

"github.com/filecoin-project/lotus/extern/sector-storage/fsutil"
Expand Down
2 changes: 1 addition & 1 deletion node/repo/retrievalstoremgr/retrievalstoremgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/query"
dss "github.com/ipfs/go-datastore/sync"
blockstore "github.com/ipfs/go-ipfs-blockstore"
format "github.com/ipfs/go-ipld-format"
dag "github.com/ipfs/go-merkledag"
"github.com/stretchr/testify/require"

"github.com/filecoin-project/go-multistore"

"github.com/filecoin-project/lotus/lib/blockstore"
"github.com/filecoin-project/lotus/node/repo/importmgr"
"github.com/filecoin-project/lotus/node/repo/retrievalstoremgr"
)
Expand Down