Fix some blockstore type mixups
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
Łukasz Magiera committed
Apr 1, 2019 at 17:17 UTC
1acb450332f8e51087886384cccb279d046cbdb3
3 files changed
+14
-7
core/core.go
+1
-1
@@ -109,7 +109,7 @@ type IpfsNode struct {
109
Peerstore pstore.Peerstore `optional:"true"` // storage for other Peer instances
110
Blockstore bstore.GCBlockstore // the block store (lower level)
111
Filestore *filestore.Filestore // the filestore blockstore
112
- BaseBlocks bstore.Blockstore // the raw blockstore, no filestore wrapping
112
+ BaseBlocks BaseBlocks // the raw blockstore, no filestore wrapping
113
GCLocker bstore.GCLocker // the locker used to protect the blockstore during gc
114
Blocks bserv.BlockService // the block service, get/add blocks.
115
DAG ipld.DAGService // the merkle dag service, get/add objects.
core/ncore.go
+9
-6
@@ -115,7 +115,9 @@ func datastoreCtor(repo repo.Repo) ds.Datastore {
115
return repo.Datastore()
116
}
117
118
-func baseBlockstoreCtor(repo repo.Repo, cfg *iconfig.Config, bcfg *BuildCfg, lc fx.Lifecycle) (bs bstore.Blockstore, err error) {
118
+type BaseBlocks bstore.Blockstore
119
+
120
+func baseBlockstoreCtor(repo repo.Repo, cfg *iconfig.Config, bcfg *BuildCfg, lc fx.Lifecycle) (bs BaseBlocks, err error) {
121
rds := &retry.Datastore{
122
Batching: repo.Datastore(),
123
Delay: time.Millisecond * 200,
@@ -157,16 +159,17 @@ func baseBlockstoreCtor(repo repo.Repo, cfg *iconfig.Config, bcfg *BuildCfg, lc
159
return
160
}
161
160
-func gcBlockstoreCtor(repo repo.Repo, bs bstore.Blockstore, cfg *iconfig.Config) (gclocker bstore.GCLocker, gcbs bstore.GCBlockstore, fstore *filestore.Filestore) {
162
+func gcBlockstoreCtor(repo repo.Repo, bb BaseBlocks, cfg *iconfig.Config) (gclocker bstore.GCLocker, gcbs bstore.GCBlockstore, bs bstore.Blockstore, fstore *filestore.Filestore) {
163
gclocker = bstore.NewGCLocker()
162
- gcbs = bstore.NewGCBlockstore(bs, gclocker)
164
+ gcbs = bstore.NewGCBlockstore(bb, gclocker)
165
166
if cfg.Experimental.FilestoreEnabled || cfg.Experimental.UrlstoreEnabled {
167
// hash security
166
- fstore = filestore.NewFilestore(bs, repo.FileManager()) //TODO: mark optional
168
+ fstore = filestore.NewFilestore(bb, repo.FileManager()) //TODO: mark optional
169
gcbs = bstore.NewGCBlockstore(fstore, gclocker)
170
gcbs = &verifbs.VerifBSGC{GCBlockstore: gcbs}
171
}
172
+ bs = gcbs
173
return
174
}
175
@@ -574,7 +577,7 @@ func dagCtor(bs bserv.BlockService) format.DAGService {
577
return merkledag.NewDAGService(bs)
578
}
579
577
-func onlineExchangeCtor(lc fx.Lifecycle, host p2phost.Host, rt routing.IpfsRouting, bs bstore.Blockstore) exchange.Interface {
580
+func onlineExchangeCtor(lc fx.Lifecycle, host p2phost.Host, rt routing.IpfsRouting, bs bstore.GCBlockstore) exchange.Interface {
581
bitswapNetwork := bsnet.NewFromIpfsHost(host, rt)
582
return bitswap.New(lifecycleCtx(lc), bitswapNetwork, bs)
583
}
@@ -664,7 +667,7 @@ func providerCtor(lc fx.Lifecycle, queue *provider.Queue, rt routing.IpfsRouting
667
return provider.NewProvider(lifecycleCtx(lc), queue, rt)
668
}
669
667
-func reproviderCtor(lc fx.Lifecycle, cfg *iconfig.Config, bs bstore.Blockstore, ds format.DAGService, pinning pin.Pinner, rt routing.IpfsRouting) (*rp.Reprovider, error) {
670
+func reproviderCtor(lc fx.Lifecycle, cfg *iconfig.Config, bs BaseBlocks, ds format.DAGService, pinning pin.Pinner, rt routing.IpfsRouting) (*rp.Reprovider, error) {
671
var keyProvider rp.KeyChanFunc
672
673
switch cfg.Reprovider.Strategy {
test/sharness/t0270-filestore.sh
+4
@@ -74,6 +74,8 @@ init_ipfs_filestore() {
74
grep "either the filestore or the urlstore must be enabled" add_out
75
'
76
77
+ assert_repo_size_less_than 1000000
78
+
79
test_expect_success "enable urlstore config setting" '
80
ipfs config --json Experimental.UrlstoreEnabled true
81
'
@@ -84,6 +86,8 @@ init_ipfs_filestore() {
86
grep "filestore is not enabled" add_out
87
'
88
89
+ assert_repo_size_less_than 1000000
90
+
91
test_expect_success "enable filestore config setting" '
92
ipfs config --json Experimental.UrlstoreEnabled true &&
93
ipfs config --json Experimental.FilestoreEnabled true