Filter Errored Keys from Returned Slashing Protection History in Standard API (#9968)

* add err condition

* naming
This commit is contained in:
Raul Jordan
2021-12-01 22:32:34 -05:00
committed by GitHub
parent 790bf03123
commit 1d216a8737
2 changed files with 13 additions and 7 deletions

View File

@@ -90,8 +90,14 @@ func (s *Server) DeleteKeystores(
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not delete keys: %v", err)
}
keysToFilter := req.PublicKeys
exportedHistory, err := slashingprotection.ExportStandardProtectionJSON(ctx, s.valDB, keysToFilter...)
// We select keys that were deleted for retrieving slashing protection history.
filteredKeys := make([][]byte, 0, len(req.PublicKeys))
for i, st := range statuses {
if st.Status != ethpbservice.DeletedKeystoreStatus_ERROR {
filteredKeys = append(filteredKeys, req.PublicKeys[i])
}
}
exportedHistory, err := slashingprotection.ExportStandardProtectionJSON(ctx, s.valDB, filteredKeys...)
if err != nil {
return nil, status.Errorf(
codes.Internal,