use of tech.pegasys.teku.validator.client.restapi.apis.schema.DeleteRemoteKeysResponse in project teku by ConsenSys.
the class ActiveKeyManager method deleteExternalValidators.
@Override
public DeleteRemoteKeysResponse deleteExternalValidators(List<BLSPublicKey> validators) {
final List<DeleteKeyResult> deletionResults = new ArrayList<>();
for (final BLSPublicKey publicKey : validators) {
Optional<Validator> maybeValidator = validatorLoader.getOwnedValidators().getValidator(publicKey);
// read-only check in a non-destructive manner
if (maybeValidator.isPresent() && maybeValidator.get().isReadOnly()) {
deletionResults.add(DeleteKeyResult.error("Cannot remove read-only validator"));
continue;
}
// delete validator from owned validators list
maybeValidator = validatorLoader.getOwnedValidators().getValidator(publicKey);
if (maybeValidator.isPresent()) {
DeleteKeyResult result = deleteExternalValidator(maybeValidator.get());
deletionResults.add(result);
if (result.equals(DeleteKeyResult.success())) {
validatorLoader.getOwnedValidators().removeValidator(publicKey);
}
} else {
deletionResults.add(DeleteKeyResult.notFound());
}
}
return new DeleteRemoteKeysResponse(deletionResults);
}
Aggregations