fix: not allowing new peer results
All checks were successful
Go Bump / bump (push) Successful in 35s
Go Test / test (push) Successful in 45s
Deploy / deploy (push) Successful in 1m28s

This commit is contained in:
xuu 2023-10-20 12:05:26 -06:00
parent 87170420e4
commit db72c24de3
Signed by: xuu
GPG Key ID: 8B3B0604F164E04F

View File

@ -435,8 +435,8 @@ func (s *service) postResult(w http.ResponseWriter, r *http.Request, reqID strin
err := s.state.Use(ctx, func(ctx context.Context, state *state) error {
var ok bool
if _, ok = state.peers[peerID]; !ok {
log.Printf("peer not found: %s\n", peerID)
return fmt.Errorf("peer not found: %s", peerID)
log.Printf("peer not found: req=%s peer=%s\n", reqID, peerID)
return fmt.Errorf("peer not found: req=%s peer=%s", reqID, peerID)
}
return nil
@ -450,8 +450,8 @@ func (s *service) postResult(w http.ResponseWriter, r *http.Request, reqID strin
peerResults := &PeerResults{}
peerResults.SetStreamID(aggPeer(peerID))
err = s.es.Load(ctx, peerResults)
if err != nil {
span.RecordError(fmt.Errorf("peer not found: %w", err))
if err != nil && !errors.Is(err, ev.ErrNotFound) {
span.RecordError(fmt.Errorf("peer not found: req=%s peer=%s %w", reqID, peerID, err))
w.WriteHeader(http.StatusNotFound)
return
}