From 004e10ebcdc4228946eaf2b322205216ae527c7c Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Thu, 31 May 2018 00:32:08 +0200 Subject: [PATCH] More comments on counter logic --- x/slashing/keeper.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/x/slashing/keeper.go b/x/slashing/keeper.go index 46ed4591b2..a37c5a07b8 100644 --- a/x/slashing/keeper.go +++ b/x/slashing/keeper.go @@ -62,15 +62,17 @@ func (k Keeper) handleValidatorSignature(ctx sdk.Context, pubkey crypto.PubKey, signInfo.IndexOffset++ // Update signed block bit array & counter + // This counter just tracks the sum of the bit array + // That way we avoid needing to read/write the whole array each time previous := k.getValidatorSigningBitArray(ctx, address, index) if previous == signed { - // No need to update counter + // Array value at this index has not changed, no need to update counter } else if previous && !signed { - // Signed => unsigned, decrement counter + // Array value has changed from signed to unsigned, decrement counter k.setValidatorSigningBitArray(ctx, address, index, false) signInfo.SignedBlocksCounter-- } else if !previous && signed { - // Unsigned => signed, increment counter + // Array value has changed from unsigned to signed, increment counter k.setValidatorSigningBitArray(ctx, address, index, true) signInfo.SignedBlocksCounter++ }