提交 1acb4503 作者: Łukasz Magiera 提交者: Steven Allen

Fix some blockstore type mixups

License: MIT
Signed-off-by: 's avatarŁukasz Magiera <magik6k@gmail.com>
上级 bfaffb2d
...@@ -109,7 +109,7 @@ type IpfsNode struct { ...@@ -109,7 +109,7 @@ type IpfsNode struct {
Peerstore pstore.Peerstore `optional:"true"` // storage for other Peer instances Peerstore pstore.Peerstore `optional:"true"` // storage for other Peer instances
Blockstore bstore.GCBlockstore // the block store (lower level) Blockstore bstore.GCBlockstore // the block store (lower level)
Filestore *filestore.Filestore // the filestore blockstore Filestore *filestore.Filestore // the filestore blockstore
BaseBlocks bstore.Blockstore // the raw blockstore, no filestore wrapping BaseBlocks BaseBlocks // the raw blockstore, no filestore wrapping
GCLocker bstore.GCLocker // the locker used to protect the blockstore during gc GCLocker bstore.GCLocker // the locker used to protect the blockstore during gc
Blocks bserv.BlockService // the block service, get/add blocks. Blocks bserv.BlockService // the block service, get/add blocks.
DAG ipld.DAGService // the merkle dag service, get/add objects. DAG ipld.DAGService // the merkle dag service, get/add objects.
......
...@@ -115,7 +115,9 @@ func datastoreCtor(repo repo.Repo) ds.Datastore { ...@@ -115,7 +115,9 @@ func datastoreCtor(repo repo.Repo) ds.Datastore {
return repo.Datastore() return repo.Datastore()
} }
func baseBlockstoreCtor(repo repo.Repo, cfg *iconfig.Config, bcfg *BuildCfg, lc fx.Lifecycle) (bs bstore.Blockstore, err error) { type BaseBlocks bstore.Blockstore
func baseBlockstoreCtor(repo repo.Repo, cfg *iconfig.Config, bcfg *BuildCfg, lc fx.Lifecycle) (bs BaseBlocks, err error) {
rds := &retry.Datastore{ rds := &retry.Datastore{
Batching: repo.Datastore(), Batching: repo.Datastore(),
Delay: time.Millisecond * 200, Delay: time.Millisecond * 200,
...@@ -157,16 +159,17 @@ func baseBlockstoreCtor(repo repo.Repo, cfg *iconfig.Config, bcfg *BuildCfg, lc ...@@ -157,16 +159,17 @@ func baseBlockstoreCtor(repo repo.Repo, cfg *iconfig.Config, bcfg *BuildCfg, lc
return return
} }
func gcBlockstoreCtor(repo repo.Repo, bs bstore.Blockstore, cfg *iconfig.Config) (gclocker bstore.GCLocker, gcbs bstore.GCBlockstore, fstore *filestore.Filestore) { func gcBlockstoreCtor(repo repo.Repo, bb BaseBlocks, cfg *iconfig.Config) (gclocker bstore.GCLocker, gcbs bstore.GCBlockstore, bs bstore.Blockstore, fstore *filestore.Filestore) {
gclocker = bstore.NewGCLocker() gclocker = bstore.NewGCLocker()
gcbs = bstore.NewGCBlockstore(bs, gclocker) gcbs = bstore.NewGCBlockstore(bb, gclocker)
if cfg.Experimental.FilestoreEnabled || cfg.Experimental.UrlstoreEnabled { if cfg.Experimental.FilestoreEnabled || cfg.Experimental.UrlstoreEnabled {
// hash security // hash security
fstore = filestore.NewFilestore(bs, repo.FileManager()) //TODO: mark optional fstore = filestore.NewFilestore(bb, repo.FileManager()) //TODO: mark optional
gcbs = bstore.NewGCBlockstore(fstore, gclocker) gcbs = bstore.NewGCBlockstore(fstore, gclocker)
gcbs = &verifbs.VerifBSGC{GCBlockstore: gcbs} gcbs = &verifbs.VerifBSGC{GCBlockstore: gcbs}
} }
bs = gcbs
return return
} }
...@@ -574,7 +577,7 @@ func dagCtor(bs bserv.BlockService) format.DAGService { ...@@ -574,7 +577,7 @@ func dagCtor(bs bserv.BlockService) format.DAGService {
return merkledag.NewDAGService(bs) return merkledag.NewDAGService(bs)
} }
func onlineExchangeCtor(lc fx.Lifecycle, host p2phost.Host, rt routing.IpfsRouting, bs bstore.Blockstore) exchange.Interface { func onlineExchangeCtor(lc fx.Lifecycle, host p2phost.Host, rt routing.IpfsRouting, bs bstore.GCBlockstore) exchange.Interface {
bitswapNetwork := bsnet.NewFromIpfsHost(host, rt) bitswapNetwork := bsnet.NewFromIpfsHost(host, rt)
return bitswap.New(lifecycleCtx(lc), bitswapNetwork, bs) return bitswap.New(lifecycleCtx(lc), bitswapNetwork, bs)
} }
...@@ -664,7 +667,7 @@ func providerCtor(lc fx.Lifecycle, queue *provider.Queue, rt routing.IpfsRouting ...@@ -664,7 +667,7 @@ func providerCtor(lc fx.Lifecycle, queue *provider.Queue, rt routing.IpfsRouting
return provider.NewProvider(lifecycleCtx(lc), queue, rt) return provider.NewProvider(lifecycleCtx(lc), queue, rt)
} }
func reproviderCtor(lc fx.Lifecycle, cfg *iconfig.Config, bs bstore.Blockstore, ds format.DAGService, pinning pin.Pinner, rt routing.IpfsRouting) (*rp.Reprovider, error) { func reproviderCtor(lc fx.Lifecycle, cfg *iconfig.Config, bs BaseBlocks, ds format.DAGService, pinning pin.Pinner, rt routing.IpfsRouting) (*rp.Reprovider, error) {
var keyProvider rp.KeyChanFunc var keyProvider rp.KeyChanFunc
switch cfg.Reprovider.Strategy { switch cfg.Reprovider.Strategy {
......
...@@ -74,6 +74,8 @@ init_ipfs_filestore() { ...@@ -74,6 +74,8 @@ init_ipfs_filestore() {
grep "either the filestore or the urlstore must be enabled" add_out grep "either the filestore or the urlstore must be enabled" add_out
' '
assert_repo_size_less_than 1000000
test_expect_success "enable urlstore config setting" ' test_expect_success "enable urlstore config setting" '
ipfs config --json Experimental.UrlstoreEnabled true ipfs config --json Experimental.UrlstoreEnabled true
' '
...@@ -84,6 +86,8 @@ init_ipfs_filestore() { ...@@ -84,6 +86,8 @@ init_ipfs_filestore() {
grep "filestore is not enabled" add_out grep "filestore is not enabled" add_out
' '
assert_repo_size_less_than 1000000
test_expect_success "enable filestore config setting" ' test_expect_success "enable filestore config setting" '
ipfs config --json Experimental.UrlstoreEnabled true && ipfs config --json Experimental.UrlstoreEnabled true &&
ipfs config --json Experimental.FilestoreEnabled true ipfs config --json Experimental.FilestoreEnabled true
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论