Update ordering logic

This commit is contained in:
Christopher Goes 2018-04-12 12:37:38 +02:00
parent 166711742e
commit 6424bb85ff
No known key found for this signature in database
GPG Key ID: E828D98232D328D3
1 changed files with 8 additions and 3 deletions

View File

@ -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()
}