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/exported"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper"
|
|
|
|
)
|
|
|
|
|
|
|
|
// BeginBlocker updates an existing localhost client with the latest block height.
|
|
|
|
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
|
2020-07-27 11:43:09 -07:00
|
|
|
_, found := k.GetClientState(ctx, exported.ClientTypeLocalHost)
|
2020-04-17 19:36:12 -07:00
|
|
|
if !found {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// update the localhost client with the latest block height
|
2020-07-27 11:43:09 -07:00
|
|
|
_, err := k.UpdateClient(ctx, exported.ClientTypeLocalHost, nil)
|
2020-04-17 19:36:12 -07:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|