mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 11:11:20 +00:00
3861c0cf06
Former-commit-id: 0ecc597de035e61ca219f4f30695cb8db59c129b [formerly da9312c1c9d69010083f94f387fe6a52aa817683] Former-commit-id: 8c8c218e16ef248ae8954168cf7bf5aa6ed6839d
27 lines
822 B
Go
27 lines
822 B
Go
// Package database provides several constructs including a simple in-memory database.
|
|
// This should not be used for production, but would be a helpful interim
|
|
// solution for development.
|
|
package database
|
|
|
|
import (
|
|
"path/filepath"
|
|
|
|
"github.com/ethereum/go-ethereum/ethdb"
|
|
)
|
|
|
|
// ShardBackend defines an interface for a shardDB's necessary method
|
|
// signatures.
|
|
type ShardBackend interface {
|
|
Get(k []byte) ([]byte, error)
|
|
Has(k []byte) (bool, error)
|
|
Put(k []byte, val []byte) error
|
|
Delete(k []byte) error
|
|
}
|
|
|
|
// NewShardDB initializes a shardDB that writes to local disk.
|
|
func NewShardDB(dataDir string, name string) (ShardBackend, error) {
|
|
// Uses default cache and handles values.
|
|
// TODO: allow these arguments to be set based on cli context.
|
|
return ethdb.NewLDBDatabase(filepath.Join(dataDir, name), 16, 16)
|
|
}
|