-
Notifications
You must be signed in to change notification settings - Fork 199
/
db.go
33 lines (27 loc) · 1.19 KB
/
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
28
29
30
31
32
33
package database
import (
"github.com/ElrondNetwork/elrond-go-storage/leveldb"
"github.com/ElrondNetwork/elrond-go-storage/memorydb"
"github.com/ElrondNetwork/elrond-go/storage"
)
// MemDB represents the memory database storage. It holds a map of key value pairs
// and a mutex to handle concurrent accesses to the map
type MemDB = memorydb.DB
// NewMemDB creates a new memorydb object
func NewMemDB() *MemDB {
return memorydb.New()
}
// NewlruDB creates a lruDB according to size
func NewlruDB(size uint32) (storage.Persister, error) {
return memorydb.NewlruDB(size)
}
// NewLevelDB is a constructor for the leveldb persister
// It creates the files in the location given as parameter
func NewLevelDB(path string, batchDelaySeconds int, maxBatchSize int, maxOpenFiles int) (s *leveldb.DB, err error) {
return leveldb.NewDB(path, batchDelaySeconds, maxBatchSize, maxOpenFiles)
}
// NewSerialDB is a constructor for the leveldb persister
// It creates the files in the location given as parameter
func NewSerialDB(path string, batchDelaySeconds int, maxBatchSize int, maxOpenFiles int) (s *leveldb.SerialDB, err error) {
return leveldb.NewSerialDB(path, batchDelaySeconds, maxBatchSize, maxOpenFiles)
}