replace deprecated toSet(...) with toHashSet(...); replace implicit with more explicit default constructor for readability

This commit is contained in:
Dustin Brody 2019-11-13 14:18:01 +01:00
parent 5a54c823d8
commit 3dcc00779a
3 changed files with 8 additions and 8 deletions

View File

@ -181,7 +181,7 @@ func bls_verify*(
# TODO bls_verify_multiple(...) used to have this workaround, and now it # TODO bls_verify_multiple(...) used to have this workaround, and now it
# lives here. No matter the signature, there's also no meaningful way to # lives here. No matter the signature, there's also no meaningful way to
# verify it -- it's a kind of vacuous truth. No pubkey/sig pairs. # verify it -- it's a kind of vacuous truth. No pubkey/sig pairs.
if pubkey == ValidatorPubKey(): if pubkey == default(ValidatorPubKey):
return true return true
sig.blsValue.verify(msg, domain, pubkey.blsValue) sig.blsValue.verify(msg, domain, pubkey.blsValue)

View File

@ -245,8 +245,8 @@ proc process_attester_slashing*(
## verify_indexed_attestation, but go by spec unless there ## verify_indexed_attestation, but go by spec unless there
## is compelling perf evidence otherwise. ## is compelling perf evidence otherwise.
for index in sorted(toSeq(intersection( for index in sorted(toSeq(intersection(
toSet(attestation_1.attesting_indices), toHashSet(attestation_1.attesting_indices),
toSet(attestation_2.attesting_indices)).items), system.cmp): toHashSet(attestation_2.attesting_indices)).items), system.cmp):
if is_slashable_validator( if is_slashable_validator(
state.validators[index.int], get_current_epoch(state)): state.validators[index.int], get_current_epoch(state)):
slash_validator(state, index.ValidatorIndex, stateCache) slash_validator(state, index.ValidatorIndex, stateCache)
@ -384,9 +384,9 @@ proc processBlock*(
# Adds nontrivial additional computation, but only does so when metrics # Adds nontrivial additional computation, but only does so when metrics
# enabled. # enabled.
beacon_current_live_validators.set(toSet( beacon_current_live_validators.set(toHashSet(
mapIt(state.current_epoch_attestations, it.proposerIndex)).len.int64) mapIt(state.current_epoch_attestations, it.proposerIndex)).len.int64)
beacon_previous_live_validators.set(toSet( beacon_previous_live_validators.set(toHashSet(
mapIt(state.previous_epoch_attestations, it.proposerIndex)).len.int64) mapIt(state.previous_epoch_attestations, it.proposerIndex)).len.int64)
if not process_block_header(state, blck, flags, stateCache): if not process_block_header(state, blck, flags, stateCache):

View File

@ -128,7 +128,7 @@ proc process_justification_and_finalization*(
# This is a somewhat expensive approach # This is a somewhat expensive approach
let active_validator_indices = let active_validator_indices =
toSet(mapIt( toHashSet(mapIt(
get_active_validator_indices(state, get_current_epoch(state)), it.int)) get_active_validator_indices(state, get_current_epoch(state)), it.int))
let matching_target_attestations_previous = let matching_target_attestations_previous =
@ -147,11 +147,11 @@ proc process_justification_and_finalization*(
trace "Non-attesting indices in previous epoch", trace "Non-attesting indices in previous epoch",
missing_all_validators= missing_all_validators=
difference(active_validator_indices, difference(active_validator_indices,
toSet(mapIt(get_attesting_indices(state, toHashSet(mapIt(get_attesting_indices(state,
matching_target_attestations_previous, stateCache), it.int))), matching_target_attestations_previous, stateCache), it.int))),
missing_unslashed_validators= missing_unslashed_validators=
difference(active_validator_indices, difference(active_validator_indices,
toSet(mapIt(get_unslashed_attesting_indices(state, toHashSet(mapIt(get_unslashed_attesting_indices(state,
matching_target_attestations_previous, stateCache), it.int))), matching_target_attestations_previous, stateCache), it.int))),
prev_attestations_len=len(state.previous_epoch_attestations), prev_attestations_len=len(state.previous_epoch_attestations),
cur_attestations_len=len(state.current_epoch_attestations), cur_attestations_len=len(state.current_epoch_attestations),