-
Notifications
You must be signed in to change notification settings - Fork 2
/
deal_counter.go
executable file
·33 lines (27 loc) · 999 Bytes
/
deal_counter.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 keeper
import (
"github.com/Harry-027/deal/x/deal/types"
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// SetDealCounter set dealCounter in the store
func (k Keeper) SetDealCounter(ctx sdk.Context, dealCounter types.DealCounter) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DealCounterKey))
b := k.cdc.MustMarshal(&dealCounter)
store.Set([]byte{0}, b)
}
// GetDealCounter returns dealCounter
func (k Keeper) GetDealCounter(ctx sdk.Context) (val types.DealCounter, found bool) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DealCounterKey))
b := store.Get([]byte{0})
if b == nil {
return val, false
}
k.cdc.MustUnmarshal(b, &val)
return val, true
}
// RemoveDealCounter removes dealCounter from the store
func (k Keeper) RemoveDealCounter(ctx sdk.Context) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DealCounterKey))
store.Delete([]byte{0})
}