From b8b4fe24e3386a1b4a22c144cd812f5cdfd1c249 Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Tue, 29 May 2018 02:33:01 +0200 Subject: [PATCH] Absent validators map[crypto.PubKey]struct{} --- x/slashing/tick.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/x/slashing/tick.go b/x/slashing/tick.go index abec2b3751..0d200f5934 100644 --- a/x/slashing/tick.go +++ b/x/slashing/tick.go @@ -30,17 +30,21 @@ func NewBeginBlocker(sk Keeper) sdk.BeginBlocker { } // Figure out which validators were absent - absent := make(map[string]bool) + absent := make(map[crypto.PubKey]struct{}) for _, pubkey := range req.AbsentValidators { var pk crypto.PubKey sk.cdc.MustUnmarshalBinary(pubkey, &pk) - absent[string(pk.Bytes())] = true + absent[pk] = struct{}{} } // Iterate over all the validators which *should* have signed this block sk.stakeKeeper.IterateValidatorsBonded(ctx, func(_ int64, validator sdk.Validator) (stop bool) { pubkey := validator.GetPubKey() - sk.handleValidatorSignature(ctx, pubkey, !absent[string(pubkey.Bytes())]) + abs := false + if _, ok := absent[pubkey]; ok { + abs = true + } + sk.handleValidatorSignature(ctx, pubkey, abs) return false })