2020-04-17 19:36:12 -07:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper"
|
2020-09-02 09:38:50 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/ibc/exported"
|
2020-04-17 19:36:12 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
// BeginBlocker updates an existing localhost client with the latest block height.
|
|
|
|
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
|
2020-09-22 07:25:58 -07:00
|
|
|
_, found := k.GetClientState(ctx, exported.Localhost)
|
2020-04-17 19:36:12 -07:00
|
|
|
if !found {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// update the localhost client with the latest block height
|
2020-09-22 07:25:58 -07:00
|
|
|
if err := k.UpdateClient(ctx, exported.Localhost, nil); err != nil {
|
2020-04-17 19:36:12 -07:00
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|