From 7fa634e772952cde9b0de68c8eff5fdc2228752a Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Mon, 9 Apr 2018 12:17:45 +0200 Subject: [PATCH] Cleanup implementation --- x/stake/keeper.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/x/stake/keeper.go b/x/stake/keeper.go index 7f35da1a9..a51877b3c 100644 --- a/x/stake/keeper.go +++ b/x/stake/keeper.go @@ -80,6 +80,9 @@ func (k Keeper) setCandidate(ctx sdk.Context, candidate Candidate) { // retreive the old candidate record oldCandidate, oldFound := k.GetCandidate(ctx, address) + // update the validator block height (will only get written if stake has changed) + candidate.ValidatorHeight = ctx.BlockHeight() + // marshal the candidate record and add to the state bz, err := k.cdc.MarshalBinary(candidate) if err != nil { @@ -87,6 +90,13 @@ func (k Keeper) setCandidate(ctx sdk.Context, candidate Candidate) { } store.Set(GetCandidateKey(candidate.Address), bz) + // marshal the new validator record + validator := candidate.validator() + bz, err = k.cdc.MarshalBinary(validator) + if err != nil { + panic(err) + } + // if the voting power is the same no need to update any of the other indexes if oldFound && oldCandidate.Assets.Equal(candidate.Assets) { return