small validator pool proc/func and unused symbol cleanup (#4945)

This commit is contained in:
tersec 2023-05-12 19:21:43 +00:00 committed by GitHub
parent ea97e93e74
commit a9f080d92d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)