Skip to content

Commit

Permalink
rename update to UpdateState
Browse files Browse the repository at this point in the history
  • Loading branch information
damiannolan committed Mar 11, 2022
1 parent d6d9920 commit 51465ee
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions modules/light-clients/06-solomachine/types/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ func (cs ClientState) CheckHeaderAndUpdateState(
return nil, nil, err
}

smHeader := msg.(*Header)
clientState, consensusState := update(&cs, smHeader)
return clientState, consensusState, nil
return cs.UpdateState(ctx, cdc, clientStore, msg)
}

// VerifyClientMessage checks if the Solo Machine update signature(s) is valid.
Expand Down Expand Up @@ -86,16 +84,19 @@ func (cs ClientState) VerifyClientMessage(cdc codec.BinaryCodec, clientMsg expor
return nil
}

// update the consensus state to the new public key and an incremented sequence
func update(clientState *ClientState, header *Header) (*ClientState, *ConsensusState) {
// UpdateState updates the consensus state to the new public key and an incremented sequence.
func (cs ClientState) UpdateState(
ctx sdk.Context, cdc codec.BinaryCodec, clientStore sdk.KVStore,
header exported.Header,
) (exported.ClientState, exported.ConsensusState, error) {
smHeader := header.(*Header)
consensusState := &ConsensusState{
PublicKey: header.NewPublicKey,
Diversifier: header.NewDiversifier,
Timestamp: header.Timestamp,
PublicKey: smHeader.NewPublicKey,
Diversifier: smHeader.NewDiversifier,
Timestamp: smHeader.Timestamp,
}

// increment sequence number
clientState.Sequence++
clientState.ConsensusState = consensusState
return clientState, consensusState
cs.Sequence++
cs.ConsensusState = consensusState
return &cs, consensusState, nil
}

0 comments on commit 51465ee

Please sign in to comment.