From 6424bb85ff1addd3ba13851840f2966e0f4d5914 Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Thu, 12 Apr 2018 12:37:38 +0200 Subject: [PATCH] Update ordering logic --- x/stake/keeper.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/x/stake/keeper.go b/x/stake/keeper.go index 8cce331cff..88d82650a5 100644 --- a/x/stake/keeper.go +++ b/x/stake/keeper.go @@ -94,11 +94,16 @@ func (k Keeper) setCandidate(ctx sdk.Context, candidate Candidate) { // update the list ordered by voting power if oldFound { - // retain the old validator height, even though stake has changed - candidate.ValidatorHeight = oldCandidate.ValidatorHeight + if k.isNewValidator(ctx, store, candidate.Address) { + // already in the validator set - retain the old validator height + candidate.ValidatorHeight = oldCandidate.ValidatorHeight + } else { + // wasn't in the validator set, update the validator block height + candidate.ValidatorHeight = ctx.BlockHeight() + } store.Delete(GetValidatorKey(address, oldCandidate.Assets, oldCandidate.ValidatorHeight, k.cdc)) } else { - // update the validator block height + // wasn't a candidate, update the validator block height candidate.ValidatorHeight = ctx.BlockHeight() }