Skip to content

Commit

Permalink
chore: add 668 functions to localhost client
Browse files Browse the repository at this point in the history
  • Loading branch information
notbdu committed Feb 11, 2022
1 parent d5e2ba5 commit 8e14e50
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions modules/light-clients/09-localhost/types/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ func (cs ClientState) ExportMetadata(_ sdk.KVStore) []exported.GenesisMetadata {

// CheckHeaderAndUpdateState updates the localhost client. It only needs access to the context
func (cs *ClientState) CheckHeaderAndUpdateState(
ctx sdk.Context, cdc codec.BinaryCodec, clientStore sdk.KVStore, header exported.Header,
) (exported.ClientState, exported.ConsensusState, error) {
return cs.UpdateState(ctx, cdc, clientStore, header)
}

// VerifyHeader is a no-op.
func (cs *ClientState) VerifyHeader(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.Header,
) (exported.ClientState, exported.ConsensusState, error) {
return cs, nil, nil
}

// CheckForMisbehaviour returns false.
func (cs *ClientState) CheckForMisbehaviour(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.Header,
) (bool, error) {
return false, nil
}

// UpdateState updates the localhost client. It only needs access to the context
func (cs *ClientState) UpdateState(
ctx sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.Header,
) (exported.ClientState, exported.ConsensusState, error) {
// use the chain ID from context since the localhost client is from the running chain (i.e self).
Expand All @@ -88,6 +109,13 @@ func (cs *ClientState) CheckHeaderAndUpdateState(
return cs, nil, nil
}

// UpdateStateOnMisbehaviour returns an error (no misbehaviour case).
func (cs *ClientState) UpdateStateOnMisbehaviour(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.Header,
) (*ClientState, error) {
return nil, sdkerrors.Wrapf(clienttypes.ErrUpdateClientFailed, "cannot update localhost client on misbehaviour")
}

// CheckMisbehaviourAndUpdateState implements ClientState
// Since localhost is the client of the running chain, misbehaviour cannot be submitted to it
// Thus, CheckMisbehaviourAndUpdateState returns an error for localhost
Expand Down

0 comments on commit 8e14e50

Please sign in to comment.