Skip to content

Commit

Permalink
Migrate to new flatfs
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
  • Loading branch information
Kubuxu committed Mar 17, 2017
1 parent b962c86 commit 4cd09ce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
6 changes: 5 additions & 1 deletion repo/config/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type S3Datastore struct {

type FlatDS struct {
Path string
PrefixLen int
ShardFunc string
Sync bool
}

Expand All @@ -34,6 +34,10 @@ type LevelDB struct {
Compression string
}

type SbsDS struct {
Path string
}

// DataStorePath returns the default data store path given a configuration root
// (set an empty string to have the default configuration root)
func DataStorePath(configroot string) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion repo/config/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func datastoreConfig() (*Datastore, error) {
"type": "flatfs",
"path": "blocks",
"nosync": false,
"prefixLen": 4,
"shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
},
},
map[string]interface{}{
Expand Down
15 changes: 11 additions & 4 deletions repo/fsrepo/datastores.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import (

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

measure "gx/ipfs/QmNPv1yzXBqxzqjfTzHCeBoicxxZgHzLezdY2hMCZ3r6EU/go-ds-measure"
flatfs "gx/ipfs/QmXZEfbEv9sXG9JnLoMNhREDMDgkq5Jd7uWJ7d77VJ4pxn/go-ds-flatfs"

ds "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore"
mount "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore/syncmount"

levelds "gx/ipfs/QmaHHmfEozrrotyhyN44omJouyuEtx6ahddqV6W5yRaUSQ/go-ds-leveldb"
ldbopts "gx/ipfs/QmbBhyDKsY4mbY6xsKt3qu9Y7FPvMJ6qbD8AMjYYvPRw1g/goleveldb/leveldb/opt"
"gx/ipfs/QmbUSMTQtK9GRrUbD4ngqJwSzHsquUc8nyDubRWp4vPybH/go-ds-measure"
"gx/ipfs/Qmbx2KUs8mUbDUiiESzC1ms7mdmh4pRu8X1V1tffC46M4n/go-ds-flatfs"
)

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

plen := int(params["prefixLen"].(float64))
return flatfs.New(p, plen, params["nosync"].(bool))
sshardFun := params["shardFunc"].(string)
shardFun, err := flatfs.ParseShardFunc(sshardFun)
if err != nil {
return nil, err
}

return flatfs.CreateOrOpen(p, shardFun, params["nosync"].(bool))
}

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

0 comments on commit 4cd09ce

Please sign in to comment.