-
Notifications
You must be signed in to change notification settings - Fork 0
/
self_consensus_state.go
32 lines (27 loc) · 1.18 KB
/
self_consensus_state.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
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
ibctmtypes "github.com/cosmos/ibc-go/v5/modules/light-clients/07-tendermint/types"
"github.com/ingenuity-build/quicksilver/x/claimsmanager/types"
)
// GetSelfConsensusState returns consensus state stored every epoch
func (k Keeper) GetSelfConsensusState(ctx sdk.Context, key string) (ibctmtypes.ConsensusState, bool) {
store := ctx.KVStore(k.storeKey)
var selfConsensusState ibctmtypes.ConsensusState
bz := store.Get(append(types.KeySelfConsensusState, []byte(key)...))
if bz == nil {
return selfConsensusState, false
}
k.cdc.MustUnmarshal(bz, &selfConsensusState)
return selfConsensusState, true
}
// SetSelfConsensusState sets the self consensus state
func (k Keeper) SetSelfConsensusState(ctx sdk.Context, key string, consState *ibctmtypes.ConsensusState) {
store := ctx.KVStore(k.storeKey)
store.Set(append(types.KeySelfConsensusState, []byte(key)...), k.cdc.MustMarshal(consState))
}
// DeleteSelfConsensusState deletes the self consensus state
func (k Keeper) DeleteSelfConsensusState(ctx sdk.Context, key string) {
store := ctx.KVStore(k.storeKey)
store.Delete(append(types.KeySelfConsensusState, []byte(key)...))
}