Skip to content

Commit

Permalink
Merge branch 'master' into chair28980-auto-assign-pr
Browse files Browse the repository at this point in the history
  • Loading branch information
chair28980 authored Sep 21, 2023
2 parents ba3f5b6 + 3254d28 commit 33645e7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/waku/server/rest/debug_api.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
openapi: 3.0.3
info:
title: Waku V2 node REST API
title: Waku V2 node Debug REST API
version: 1.0.0
contact:
name: VAC Team
Expand Down
26 changes: 15 additions & 11 deletions cmd/waku/server/rest/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,23 @@ func NewHealthService(node *node.WakuNode, m *chi.Mux) *HealthService {
type HealthResponse string

func (d *HealthService) getHealth(w http.ResponseWriter, r *http.Request) {
isReady, err := d.node.RLNRelay().IsReady(r.Context())
if err != nil {
if errors.Is(err, context.DeadlineExceeded) {
writeResponse(w, HealthResponse("Health check timed out"), http.StatusInternalServerError)
} else {
writeResponse(w, HealthResponse(err.Error()), http.StatusInternalServerError)
if d.node.RLNRelay() != nil {
isReady, err := d.node.RLNRelay().IsReady(r.Context())
if err != nil {
if errors.Is(err, context.DeadlineExceeded) {
writeResponse(w, HealthResponse("Health check timed out"), http.StatusInternalServerError)
} else {
writeResponse(w, HealthResponse(err.Error()), http.StatusInternalServerError)
}
return
}
return
}

if isReady {
writeResponse(w, HealthResponse("Node is healthy"), http.StatusOK)
if isReady {
writeResponse(w, HealthResponse("Node is healthy"), http.StatusOK)
} else {
writeResponse(w, HealthResponse("Node is not ready"), http.StatusInternalServerError)
}
} else {
writeResponse(w, HealthResponse("Node is not ready"), http.StatusInternalServerError)
writeResponse(w, HealthResponse("Non RLN healthcheck is not implemented"), http.StatusNotImplemented)
}
}
2 changes: 1 addition & 1 deletion cmd/waku/server/rest/health_api.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
openapi: 3.0.3
info:
title: Waku V2 node REST API
title: Waku V2 node Health REST API
version: 1.0.0
contact:
name: VAC Team
Expand Down
2 changes: 1 addition & 1 deletion cmd/waku/server/rest/relay_api.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
openapi: 3.0.3
info:
title: Waku V2 node REST API
title: Waku V2 node Relay REST API
version: 1.0.0
contact:
name: VAC Team
Expand Down
2 changes: 1 addition & 1 deletion cmd/waku/server/rest/store_api.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
openapi: 3.0.3
info:
title: Waku V2 node REST API
title: Waku V2 node Store REST API
version: 1.0.0
contact:
name: VAC Team
Expand Down
5 changes: 5 additions & 0 deletions waku/v2/peerstore/waku_peer_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ func (ps *WakuPeerstoreImpl) RemovePubSubTopic(p peer.ID, topic string) error {
if err != nil {
return err
}

if len(existingTopics) == 0 {
return nil
}

for i := range existingTopics {
existingTopics = append(existingTopics[:i], existingTopics[i+1:]...)
}
Expand Down

0 comments on commit 33645e7

Please sign in to comment.