prysm-pulse/sharding/database/database.go
Raul Jordan 08eb16eecb sharding: use leveldb backend for shard state storage
Former-commit-id: 2b402c6cce64f0c38d6d3ce48b4818c839bec19d [formerly e3ea64a3e937d89f586af617f3b899bb950e30b7]
Former-commit-id: ddd9e507e1e49758152ddf6e8827864df700dad7
2018-05-24 17:14:52 -06:00

32 lines
862 B
Go

package database
import (
"path/filepath"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/micro/cli"
)
// ShardBackend defines an interface for a shardDB's necessary method
// signatures.
type ShardBackend interface {
Get(k common.Hash) (*[]byte, error)
Has(k common.Hash) bool
Put(k common.Hash, val []byte) error
Delete(k common.Hash) error
}
// NewShardDB initializes a shardDB that writes to local disk.
// TODO: make it return ShardBackend but modify interface methods.
func NewShardDB(ctx *cli.Context, name string) (*ethdb.LDBDatabase, error) {
dataDir := ""
path := filepath.Join(dataDir, name)
// Uses default cache and handles values.
// TODO: allow these to be set based on cli context.
// TODO: fix interface - lots of methods do not match.
return ethdb.NewLDBDatabase(path, 16, 16)
}