Skip to content

Commit

Permalink
chroe: remove start/stop for relay rest
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyaprem committed Nov 7, 2023
1 parent 1008d17 commit 9463591
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 31 deletions.
22 changes: 1 addition & 21 deletions cmd/waku/server/rest/relay.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package rest

import (
"context"
"encoding/json"
"net/http"
"strings"
Expand All @@ -23,13 +22,11 @@ const routeRelayV1AutoMessages = "/relay/v1/auto/messages"

// RelayService represents the REST service for WakuRelay
type RelayService struct {
node *node.WakuNode
cancel context.CancelFunc
node *node.WakuNode

log *zap.Logger

cacheCapacity int
ctx context.Context
}

// NewRelayService returns an instance of RelayService
Expand All @@ -40,8 +37,6 @@ func NewRelayService(node *node.WakuNode, m *chi.Mux, cacheCapacity int, log *za
cacheCapacity: cacheCapacity,
}

//s.runner = newRunnerService(node.Broadcaster(), s.addEnvelope)

m.Post(routeRelayV1Subscriptions, s.postV1Subscriptions)
m.Delete(routeRelayV1Subscriptions, s.deleteV1Subscriptions)
m.Get(routeRelayV1Messages, s.getV1Messages)
Expand All @@ -58,21 +53,6 @@ func NewRelayService(node *node.WakuNode, m *chi.Mux, cacheCapacity int, log *za
return s
}

// Start starts the RelayService
func (r *RelayService) Start(ctx context.Context) {
ctx, cancel := context.WithCancel(ctx)
r.cancel = cancel
r.ctx = ctx
}

// Stop stops the RelayService
func (r *RelayService) Stop() {
if r.cancel == nil {
return
}
r.cancel()
}

func (r *RelayService) deleteV1Subscriptions(w http.ResponseWriter, req *http.Request) {
var topics []string
decoder := json.NewDecoder(req.Body)
Expand Down
7 changes: 0 additions & 7 deletions cmd/waku/server/rest/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ func TestRelaySubscription(t *testing.T) {

r := makeRelayService(t, router)

go r.Start(context.Background())
defer r.Stop()

// Wait for node to start
time.Sleep(500 * time.Millisecond)

Expand Down Expand Up @@ -100,12 +97,8 @@ func TestRelayGetV1Messages(t *testing.T) {
router1 := chi.NewRouter()

serviceA := makeRelayService(t, router)
go serviceA.Start(context.Background())
defer serviceA.Stop()

serviceB := makeRelayService(t, router1)
go serviceB.Start(context.Background())
defer serviceB.Stop()

hostInfo, err := multiaddr.NewMultiaddr(fmt.Sprintf("/p2p/%s", serviceB.node.Host().ID().Pretty()))
require.NoError(t, err)
Expand Down
3 changes: 0 additions & 3 deletions cmd/waku/server/rest/waku_rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ func NewWakuRest(node *node.WakuNode, address string, port int, enablePProf bool

if node.Relay() != nil {
relayService := NewRelayService(node, mux, relayCacheCapacity, log)
server.RegisterOnShutdown(func() {
relayService.Stop()
})
wrpc.relayService = relayService
}

Expand Down

0 comments on commit 9463591

Please sign in to comment.