Simplify validator_id filter's logic.

This commit is contained in:
cheatfate 2021-04-09 02:02:30 +03:00 committed by zah
parent 5268d03b68
commit af1a4d0c05
1 changed files with 6 additions and 40 deletions

View File

@ -270,26 +270,9 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
var res: seq[RestValidatorTuple] var res: seq[RestValidatorTuple]
for index, validator in state().validators.pairs(): for index, validator in state().validators.pairs():
let includeFlag = let includeFlag =
if (len(keySet) == 0) and (len(indexSet) == 0): (len(keySet) == 0) and (len(indexSet) == 0) or
true (len(indexSet) > 0 and (ValidatorIndex(index) in indexSet)) or
else: (len(keySet) > 0 and (validator.pubkey in keySet))
let indexFlag =
if len(indexSet) > 0:
if ValidatorIndex(index) in indexSet:
true
else:
false
else:
false
let keyFlag =
if len(keySet) > 0:
if validator.pubkey in keySet:
true
else:
false
else:
false
indexFlag or keyFlag
let sres = validator.getStatus(current_epoch) let sres = validator.getStatus(current_epoch)
if sres.isOk(): if sres.isOk():
let vstatus = sres.get() let vstatus = sres.get()
@ -433,26 +416,9 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
var res: seq[RestValidatorBalanceTuple] var res: seq[RestValidatorBalanceTuple]
for index, validator in state().validators.pairs(): for index, validator in state().validators.pairs():
let includeFlag = let includeFlag =
if (len(keySet) == 0) and (len(indexSet) == 0): (len(keySet) == 0) and (len(indexSet) == 0) or
true (len(indexSet) > 0 and (ValidatorIndex(index) in indexSet)) or
else: (len(keySet) > 0 and (validator.pubkey in keySet))
let indexFlag =
if len(indexSet) > 0:
if ValidatorIndex(index) in indexSet:
true
else:
false
else:
false
let keyFlag =
if len(keySet) > 0:
if validator.pubkey in keySet:
true
else:
false
else:
false
indexFlag or keyFlag
let sres = validator.getStatus(current_epoch) let sres = validator.getStatus(current_epoch)
if sres.isOk(): if sres.isOk():
let vstatus = sres.get() let vstatus = sres.get()