From 65945c069c7cbc9fabbe6523fd0086054fd82a1b Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Tue, 29 May 2018 02:48:29 +0200 Subject: [PATCH] Clarify counter logic --- x/slashing/keeper.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/x/slashing/keeper.go b/x/slashing/keeper.go index b27fdb5927..46ed4591b2 100644 --- a/x/slashing/keeper.go +++ b/x/slashing/keeper.go @@ -63,10 +63,14 @@ func (k Keeper) handleValidatorSignature(ctx sdk.Context, pubkey crypto.PubKey, // Update signed block bit array & counter previous := k.getValidatorSigningBitArray(ctx, address, index) - if previous && !signed { + if previous == signed { + // No need to update counter + } else if previous && !signed { + // Signed => unsigned, decrement counter k.setValidatorSigningBitArray(ctx, address, index, false) signInfo.SignedBlocksCounter-- } else if !previous && signed { + // Unsigned => signed, increment counter k.setValidatorSigningBitArray(ctx, address, index, true) signInfo.SignedBlocksCounter++ }