2018-10-05 17:14:50 +00:00
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
2019-12-06 02:05:58 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/db/iface"
|
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/db/kafka"
|
2019-08-14 18:48:28 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/db/kv"
|
2018-10-05 17:14:50 +00:00
|
|
|
)
|
|
|
|
|
2019-08-09 19:17:18 +00:00
|
|
|
// Database defines the necessary methods for Prysm's eth2 backend which may
|
|
|
|
// be implemented by any key-value or relational database in practice.
|
2019-12-06 02:05:58 +00:00
|
|
|
type Database = iface.Database
|
2019-08-09 19:17:18 +00:00
|
|
|
|
2019-08-14 18:48:28 +00:00
|
|
|
// NewDB initializes a new DB.
|
|
|
|
func NewDB(dirPath string) (Database, error) {
|
2019-12-06 02:05:58 +00:00
|
|
|
db, err := kv.NewKVStore(dirPath)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return kafka.Wrap(db)
|
2019-08-14 18:48:28 +00:00
|
|
|
}
|