More comments on counter logic

This commit is contained in:
Christopher Goes 2018-05-31 00:32:08 +02:00
parent 99bed49c8d
commit 004e10ebcd
No known key found for this signature in database
GPG Key ID: E828D98232D328D3
1 changed files with 5 additions and 3 deletions

View File

@ -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++
}