forked from Fantom-foundation/Substate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.go
27 lines (22 loc) · 756 Bytes
/
db.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package substate
import (
"fmt"
"github.com/ethereum/go-ethereum/core/rawdb"
)
// NewDb creates a new instance of DB from given path.
func NewDb(path string, readOnly bool) (*DB, error) {
backend, err := rawdb.NewLevelDBDatabase(path, 1024, 100, substateNamespace, readOnly)
if err != nil {
return nil, fmt.Errorf("error opening leveldb %s; %v", substateDir, err)
}
return newSubstateDB(backend), nil
}
// MakeDb creates a new instance of DB from given backend.
func MakeDb(backend BackendDatabase) *DB {
// todo Rename to OpenSubstateDb after deprecated functions are removed
return newSubstateDB(backend)
}
// NewInMemoryDb creates new instance of in-memory DB
func NewInMemoryDb() *DB {
return newSubstateDB(rawdb.NewMemoryDatabase())
}