mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-27 00:35:18 +00:00
fc85052522
* feat: add community multi-spend proposal type * feat: add handler for community multi-spend proposals * chore: register new community multi-spend proposal * feat: define client for community multi-spend proposal * fix typos in example cli json * fix: register now proposal type with module codec * fix: register community multi-spend proposal with gov router, not committee * fix: define kavadist keeper before referencing it * nit: include deposit in example proposal * nit: update comment * nit: fix error codes * nit: update comments
60 lines
1.6 KiB
Go
60 lines
1.6 KiB
Go
package keeper
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
"github.com/cosmos/cosmos-sdk/store/prefix"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/x/params/subspace"
|
|
|
|
"github.com/kava-labs/kava/x/kavadist/types"
|
|
)
|
|
|
|
// Keeper keeper for the cdp module
|
|
type Keeper struct {
|
|
key sdk.StoreKey
|
|
cdc *codec.Codec
|
|
paramSubspace subspace.Subspace
|
|
supplyKeeper types.SupplyKeeper
|
|
distKeeper types.DistKeeper
|
|
|
|
blacklistedAddrs map[string]bool
|
|
}
|
|
|
|
// NewKeeper creates a new keeper
|
|
func NewKeeper(
|
|
cdc *codec.Codec, key sdk.StoreKey, paramstore subspace.Subspace, sk types.SupplyKeeper,
|
|
dk types.DistKeeper, blacklistedAddrs map[string]bool,
|
|
) Keeper {
|
|
if !paramstore.HasKeyTable() {
|
|
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
|
|
}
|
|
|
|
return Keeper{
|
|
key: key,
|
|
cdc: cdc,
|
|
paramSubspace: paramstore,
|
|
supplyKeeper: sk,
|
|
distKeeper: dk,
|
|
blacklistedAddrs: blacklistedAddrs,
|
|
}
|
|
}
|
|
|
|
// GetPreviousBlockTime get the blocktime for the previous block
|
|
func (k Keeper) GetPreviousBlockTime(ctx sdk.Context) (blockTime time.Time, found bool) {
|
|
store := prefix.NewStore(ctx.KVStore(k.key), types.PreviousBlockTimeKey)
|
|
b := store.Get([]byte{})
|
|
if b == nil {
|
|
return time.Time{}, false
|
|
}
|
|
k.cdc.MustUnmarshalBinaryLengthPrefixed(b, &blockTime)
|
|
return blockTime, true
|
|
}
|
|
|
|
// SetPreviousBlockTime set the time of the previous block
|
|
func (k Keeper) SetPreviousBlockTime(ctx sdk.Context, blockTime time.Time) {
|
|
store := prefix.NewStore(ctx.KVStore(k.key), types.PreviousBlockTimeKey)
|
|
store.Set([]byte{}, k.cdc.MustMarshalBinaryLengthPrefixed(blockTime))
|
|
}
|