Skip to content

Commit

Permalink
Merge pull request #28 from 7or2ga/info-return-empty-array
Browse files Browse the repository at this point in the history
Update 'info' endpoint to respond with 200 OK and operator info
  • Loading branch information
jshufro authored Oct 10, 2024
2 parents 3ba895b + ac37d27 commit 852254e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
7 changes: 1 addition & 6 deletions api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,7 @@ func (ar *apiRouter) GetOperatorInfo(w http.ResponseWriter, r *http.Request) err
return writeJSONError(w, err)
}

// No cred events found
if len(operatorInfo.CredentialEvents) == 0 {
return writeJSONResponse(w, http.StatusNotFound, operatorInfo, "")
}

// Cred events found
// Cred events retrieved
ar.logger.Info("Retrieved operator info",
zap.String("nodeID", req.Address),
zap.Int("operator_type", int(req.operatorType)),
Expand Down
11 changes: 1 addition & 10 deletions services/operator_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (s *Service) GetOperatorInfo(msg []byte, sig []byte, ot credentials.Operato
defer rows.Close()

// Parse credential events
var events []int64
var events = []int64{}
var credCount int64 = 0
for rows.Next() {
row_timestamp := int64(0)
Expand All @@ -47,15 +47,6 @@ func (s *Service) GetOperatorInfo(msg []byte, sig []byte, ot credentials.Operato
}
}

// Return empty if no cred events found
if credCount == 0 {
s.logger.Info(
"No creds found for operator",
zap.String("nodeID", nodeID.String()),
)
return &OperatorInfo{[]int64{}}, nil
}

s.logger.Info(
"Retrieved operator info",
zap.String("nodeID", nodeID.String()),
Expand Down

0 comments on commit 852254e

Please sign in to comment.