2018-05-22 18:36:55 +00:00
|
|
|
package database
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
|
|
|
"github.com/ethereum/go-ethereum/ethdb"
|
|
|
|
"github.com/ethereum/go-ethereum/sharding"
|
|
|
|
"github.com/micro/cli"
|
|
|
|
)
|
|
|
|
|
2018-05-22 18:49:59 +00:00
|
|
|
// NewShardDB initializes a shardDB that writes to local disk.
|
|
|
|
func NewShardDB(ctx *cli.Context, name string) (sharding.ShardBackend, error) {
|
2018-05-22 18:36:55 +00:00
|
|
|
|
2018-05-22 18:49:59 +00:00
|
|
|
dataDir := ctx.GlobalString(utils.DataDirFlag.Name)
|
2018-05-22 18:36:55 +00:00
|
|
|
path := filepath.Join(dataDir, name)
|
|
|
|
|
|
|
|
// Uses default cache and handles values.
|
2018-05-22 18:49:59 +00:00
|
|
|
// TODO: allow these to be set based on cli context.
|
|
|
|
// TODO: fix interface - lots of methods do not match.
|
2018-05-22 18:36:55 +00:00
|
|
|
return ethdb.NewLDBDatabase(path, 16, 16)
|
|
|
|
}
|