package keeper import ( "math/big" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/planetmint/planetmint-go/x/dao/types" ) func (k Keeper) StoreReissuance(ctx sdk.Context, reissuance types.Reissuance) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ReissuanceBlockHeightKey)) appendValue := k.cdc.MustMarshal(&reissuance) store.Set(getReissuanceBytes(reissuance.BlockHeight), appendValue) } func (k Keeper) GetReissuance(ctx sdk.Context, height uint64) (val types.Challenge, found bool) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ReissuanceBlockHeightKey)) reissuance := store.Get(getReissuanceBytes(height)) if reissuance == nil { return val, false } k.cdc.MustUnmarshal(reissuance, &val) return val, true } func getReissuanceBytes(height uint64) []byte { // Adding 1 because 0 will be interpreted as nil, which is an invalid key return big.NewInt(int64(height + 1)).Bytes() }