From a9f080d92d2e5b6c6d161ad55e33d486492570f1 Mon Sep 17 00:00:00 2001 From: tersec Date: Fri, 12 May 2023 19:21:43 +0000 Subject: [PATCH] small validator pool proc/func and unused symbol cleanup (#4945) --- beacon_chain/validators/validator_pool.nim | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/beacon_chain/validators/validator_pool.nim b/beacon_chain/validators/validator_pool.nim index 2ce51a42a..fb6b54d8d 100644 --- a/beacon_chain/validators/validator_pool.nim +++ b/beacon_chain/validators/validator_pool.nim @@ -43,8 +43,6 @@ type ValidatorKind* {.pure.} = enum Local, Remote - ValidatorConnection* = RestClientRef - ValidatorAndIndex* = object index*: ValidatorIndex validator*: Validator @@ -209,12 +207,12 @@ proc addValidator*(pool: var ValidatorPool, of KeystoreKind.Remote: pool.addRemoteValidator(keystore, feeRecipient, gasLimit) -proc getValidator*(pool: ValidatorPool, +func getValidator*(pool: ValidatorPool, validatorKey: ValidatorPubKey): Opt[AttachedValidator] = let v = pool.validators.getOrDefault(validatorKey) if v == nil: Opt.none(AttachedValidator) else: Opt.some(v) -proc contains*(pool: ValidatorPool, pubkey: ValidatorPubKey): bool = +func contains*(pool: ValidatorPool, pubkey: ValidatorPubKey): bool = ## Returns ``true`` if validator with key ``pubkey`` present in ``pool``. pool.validators.contains(pubkey) @@ -231,7 +229,7 @@ proc removeValidator*(pool: var ValidatorPool, pubkey: ValidatorPubKey) = validator = shortLog(validator) validators.set(pool.count().int64) -proc needsUpdate*(validator: AttachedValidator): bool = +func needsUpdate*(validator: AttachedValidator): bool = validator.index.isNone() or validator.activationEpoch == FAR_FUTURE_EPOCH proc updateValidator*( @@ -270,10 +268,6 @@ proc close*(pool: var ValidatorPool) = pubkey = validator.pubkey, validator = shortLog(validator) pool.validators.clear() -iterator publicKeys*(pool: ValidatorPool): ValidatorPubKey = - for item in pool.validators.keys(): - yield item - iterator indices*(pool: ValidatorPool): ValidatorIndex = for item in pool.validators.values(): if item.index.isSome(): @@ -338,7 +332,7 @@ func triggersDoppelganger*(v: AttachedValidator, epoch: Epoch): bool = else: v.doppelCheck.get() == epoch -proc doppelgangerReady*(validator: AttachedValidator, slot: Slot): bool = +func doppelgangerReady*(validator: AttachedValidator, slot: Slot): bool = ## Returns true iff the validator has passed doppelganger detection by being ## monitored in the previous epoch (or the given epoch is the activation ## epoch, in which case we always consider it ready)