Skip to content

Commit 4cd09ce

Browse files
committed
Migrate to new flatfs
License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
1 parent b962c86 commit 4cd09ce

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

repo/config/datastore.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type S3Datastore struct {
2525

2626
type FlatDS struct {
2727
Path string
28-
PrefixLen int
28+
ShardFunc string
2929
Sync bool
3030
}
3131

@@ -34,6 +34,10 @@ type LevelDB struct {
3434
Compression string
3535
}
3636

37+
type SbsDS struct {
38+
Path string
39+
}
40+
3741
// DataStorePath returns the default data store path given a configuration root
3842
// (set an empty string to have the default configuration root)
3943
func DataStorePath(configroot string) (string, error) {

repo/config/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func datastoreConfig() (*Datastore, error) {
9393
"type": "flatfs",
9494
"path": "blocks",
9595
"nosync": false,
96-
"prefixLen": 4,
96+
"shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
9797
},
9898
},
9999
map[string]interface{}{

repo/fsrepo/datastores.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import (
77

88
repo "github.com/ipfs/go-ipfs/repo"
99

10+
measure "gx/ipfs/QmNPv1yzXBqxzqjfTzHCeBoicxxZgHzLezdY2hMCZ3r6EU/go-ds-measure"
11+
flatfs "gx/ipfs/QmXZEfbEv9sXG9JnLoMNhREDMDgkq5Jd7uWJ7d77VJ4pxn/go-ds-flatfs"
12+
1013
ds "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore"
1114
mount "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore/syncmount"
15+
1216
levelds "gx/ipfs/QmaHHmfEozrrotyhyN44omJouyuEtx6ahddqV6W5yRaUSQ/go-ds-leveldb"
1317
ldbopts "gx/ipfs/QmbBhyDKsY4mbY6xsKt3qu9Y7FPvMJ6qbD8AMjYYvPRw1g/goleveldb/leveldb/opt"
14-
"gx/ipfs/QmbUSMTQtK9GRrUbD4ngqJwSzHsquUc8nyDubRWp4vPybH/go-ds-measure"
15-
"gx/ipfs/Qmbx2KUs8mUbDUiiESzC1ms7mdmh4pRu8X1V1tffC46M4n/go-ds-flatfs"
1618
)
1719

1820
func (r *FSRepo) constructDatastore(params map[string]interface{}) (repo.Datastore, error) {
@@ -88,8 +90,13 @@ func (r *FSRepo) openFlatfsDatastore(params map[string]interface{}) (repo.Datast
8890
p = filepath.Join(r.path, p)
8991
}
9092

91-
plen := int(params["prefixLen"].(float64))
92-
return flatfs.New(p, plen, params["nosync"].(bool))
93+
sshardFun := params["shardFunc"].(string)
94+
shardFun, err := flatfs.ParseShardFunc(sshardFun)
95+
if err != nil {
96+
return nil, err
97+
}
98+
99+
return flatfs.CreateOrOpen(p, shardFun, params["nosync"].(bool))
93100
}
94101

95102
func (r *FSRepo) openLeveldbDatastore(params map[string]interface{}) (repo.Datastore, error) {

0 commit comments

Comments
 (0)