-
Notifications
You must be signed in to change notification settings - Fork 0
/
store.go
49 lines (37 loc) · 1.06 KB
/
store.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package sfcapi
import (
"github.com/corex-mn/corex-base/kvdb"
"github.com/corex-mn/corex-base/kvdb/table"
"github.com/corex-mn/go-corex/logger"
"github.com/corex-mn/go-corex/utils/rlpstore"
)
// Store is a node persistent storage working over physical key-value database.
type Store struct {
mainDB kvdb.Store
table struct {
GasPowerRefund kvdb.Store `table:"R"`
Validators kvdb.Store `table:"1"`
Stakers kvdb.Store `table:"2"`
Delegations kvdb.Store `table:"3"`
DelegationOldRewards kvdb.Store `table:"6"`
StakerOldRewards kvdb.Store `table:"7"`
StakerDelegationsOldRewards kvdb.Store `table:"8"`
}
rlp rlpstore.Helper
logger.Instance
}
// NewStore creates store over key-value db.
func NewStore(mainDB kvdb.Store) *Store {
s := &Store{
mainDB: mainDB,
Instance: logger.MakeInstance(),
rlp: rlpstore.Helper{logger.MakeInstance()},
}
table.MigrateTables(&s.table, s.mainDB)
return s
}
// Close closes underlying database.
func (s *Store) Close() {
table.MigrateTables(&s.table, nil)
_ = s.mainDB.Close()
}