-
Notifications
You must be signed in to change notification settings - Fork 2
/
store.go
150 lines (124 loc) · 4.07 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package types
import (
cmn "github.com/hdac-io/tendermint/libs/common"
"github.com/hdac-io/friday/store/types"
)
// nolint - reexport
type (
PruningOptions = types.PruningOptions
)
// nolint - reexport
type (
Store = types.Store
Committer = types.Committer
CommitStore = types.CommitStore
Queryable = types.Queryable
MultiStore = types.MultiStore
CacheMultiStore = types.CacheMultiStore
CommitMultiStore = types.CommitMultiStore
KVStore = types.KVStore
Iterator = types.Iterator
)
// Iterator over all the keys with a certain prefix in ascending order
func KVStorePrefixIterator(kvs KVStore, prefix []byte) Iterator {
return types.KVStorePrefixIterator(kvs, prefix)
}
// Iterator over all the keys with a certain prefix in descending order.
func KVStoreReversePrefixIterator(kvs KVStore, prefix []byte) Iterator {
return types.KVStoreReversePrefixIterator(kvs, prefix)
}
// Compare two KVstores, return either the first key/value pair
// at which they differ and whether or not they are equal, skipping
// value comparison for a set of provided prefixes
func DiffKVStores(a KVStore, b KVStore, prefixesToSkip [][]byte) (kvA cmn.KVPair, kvB cmn.KVPair, count int64, equal bool) {
return types.DiffKVStores(a, b, prefixesToSkip)
}
// nolint - reexport
type (
CacheKVStore = types.CacheKVStore
CommitKVStore = types.CommitKVStore
CacheWrap = types.CacheWrap
CacheWrapper = types.CacheWrapper
CommitID = types.CommitID
)
// nolint - reexport
type StoreType = types.StoreType
// nolint - reexport
const (
StoreTypeMulti = types.StoreTypeMulti
StoreTypeDB = types.StoreTypeDB
StoreTypeIAVL = types.StoreTypeIAVL
StoreTypeTransient = types.StoreTypeTransient
)
// nolint - reexport
type (
StoreKey = types.StoreKey
KVStoreKey = types.KVStoreKey
TransientStoreKey = types.TransientStoreKey
)
// NewKVStoreKey returns a new pointer to a KVStoreKey.
// Use a pointer so keys don't collide.
func NewKVStoreKey(name string) *KVStoreKey {
return types.NewKVStoreKey(name)
}
// NewKVStoreKeys returns a map of new pointers to KVStoreKey's.
// Uses pointers so keys don't collide.
func NewKVStoreKeys(names ...string) map[string]*KVStoreKey {
keys := make(map[string]*KVStoreKey)
for _, name := range names {
keys[name] = NewKVStoreKey(name)
}
return keys
}
// Constructs new TransientStoreKey
// Must return a pointer according to the ocap principle
func NewTransientStoreKey(name string) *TransientStoreKey {
return types.NewTransientStoreKey(name)
}
// NewTransientStoreKeys constructs a new map of TransientStoreKey's
// Must return pointers according to the ocap principle
func NewTransientStoreKeys(names ...string) map[string]*TransientStoreKey {
keys := make(map[string]*TransientStoreKey)
for _, name := range names {
keys[name] = NewTransientStoreKey(name)
}
return keys
}
// PrefixEndBytes returns the []byte that would end a
// range query for all []byte with a certain prefix
// Deals with last byte of prefix being FF without overflowing
func PrefixEndBytes(prefix []byte) []byte {
return types.PrefixEndBytes(prefix)
}
// InclusiveEndBytes returns the []byte that would end a
// range query such that the input would be included
func InclusiveEndBytes(inclusiveBytes []byte) (exclusiveBytes []byte) {
return types.InclusiveEndBytes(inclusiveBytes)
}
//----------------------------------------
// key-value result for iterator queries
type KVPair = types.KVPair
//----------------------------------------
// TraceContext contains TraceKVStore context data. It will be written with
// every trace operation.
type TraceContext = types.TraceContext
// --------------------------------------
// nolint - reexport
type (
Gas = types.Gas
GasMeter = types.GasMeter
GasConfig = types.GasConfig
)
// nolint - reexport
func NewGasMeter(limit Gas) GasMeter {
return types.NewGasMeter(limit)
}
// nolint - reexport
type (
ErrorOutOfGas = types.ErrorOutOfGas
ErrorGasOverflow = types.ErrorGasOverflow
)
// nolint - reexport
func NewInfiniteGasMeter() GasMeter {
return types.NewInfiniteGasMeter()
}