forked from cerc-io/laconicd-deprecated
93a57bc330
* increase feemarket's consensus version and add migration handler Closes: #1001 * unit test * fix linter
34 lines
692 B
Go
34 lines
692 B
Go
package keeper
|
|
|
|
import (
|
|
"math/big"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
)
|
|
|
|
// KeyPrefixBaseFeeV1 is the base fee key prefix used in version 1
|
|
var KeyPrefixBaseFeeV1 = []byte{2}
|
|
|
|
// Migrator is a struct for handling in-place store migrations.
|
|
type Migrator struct {
|
|
keeper Keeper
|
|
}
|
|
|
|
// NewMigrator returns a new Migrator.
|
|
func NewMigrator(keeper Keeper) Migrator {
|
|
return Migrator{
|
|
keeper: keeper,
|
|
}
|
|
}
|
|
|
|
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
|
|
store := ctx.KVStore(m.keeper.storeKey)
|
|
bz := store.Get(KeyPrefixBaseFeeV1)
|
|
if len(bz) > 0 {
|
|
baseFee := new(big.Int).SetBytes(bz)
|
|
m.keeper.SetBaseFee(ctx, baseFee)
|
|
}
|
|
store.Delete(KeyPrefixBaseFeeV1)
|
|
return nil
|
|
}
|