mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 18:15:19 +00:00
ffef832d45
- Upgrade cosmos-sdk to v0.44.5 from v0.39.2 - Add Legacy Tx Endpoint for backwards compatibility - Add IBC v1.2.3 Support Co-authored-by: DracoLi <draco@dracoli.com> Co-authored-by: drklee3 <derrick@dlee.dev> Co-authored-by: denalimarsh <denalimarsh@gmail.com> Co-authored-by: Draco Li <draco@kava.io> Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com> Co-authored-by: Kevin Davis <karzak@users.noreply.github.com> Co-authored-by: Denali Marsh <denali@kava.io>
68 lines
1.8 KiB
Go
68 lines
1.8 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"
|
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
|
|
"github.com/kava-labs/kava/x/kavadist/types"
|
|
)
|
|
|
|
// Keeper keeper for the cdp module
|
|
type Keeper struct {
|
|
key sdk.StoreKey
|
|
cdc codec.BinaryCodec
|
|
paramSubspace paramtypes.Subspace
|
|
bankKeeper types.BankKeeper
|
|
distKeeper types.DistKeeper
|
|
accountKeeper types.AccountKeeper
|
|
|
|
blacklistedAddrs map[string]bool
|
|
}
|
|
|
|
// NewKeeper creates a new keeper
|
|
func NewKeeper(
|
|
cdc codec.BinaryCodec, key sdk.StoreKey, paramstore paramtypes.Subspace, bk types.BankKeeper, ak types.AccountKeeper,
|
|
dk types.DistKeeper, blacklistedAddrs map[string]bool,
|
|
) Keeper {
|
|
if !paramstore.HasKeyTable() {
|
|
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
|
|
}
|
|
|
|
return Keeper{
|
|
key: key,
|
|
cdc: cdc,
|
|
paramSubspace: paramstore,
|
|
bankKeeper: bk,
|
|
distKeeper: dk,
|
|
accountKeeper: ak,
|
|
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(types.PreviousBlockTimeKey)
|
|
if b == nil {
|
|
return time.Time{}, false
|
|
}
|
|
if err := blockTime.UnmarshalBinary(b); err != nil {
|
|
return time.Time{}, false
|
|
}
|
|
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)
|
|
b, err := blockTime.MarshalBinary()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
store.Set(types.PreviousBlockTimeKey, b)
|
|
}
|