From 946359171dc2338545d072e4be6c3045ac446c18 Mon Sep 17 00:00:00 2001 From: Prem Chaitanya Prathi Date: Tue, 7 Nov 2023 13:18:15 +0530 Subject: [PATCH] chroe: remove start/stop for relay rest --- cmd/waku/server/rest/relay.go | 22 +--------------------- cmd/waku/server/rest/relay_test.go | 7 ------- cmd/waku/server/rest/waku_rest.go | 3 --- 3 files changed, 1 insertion(+), 31 deletions(-) diff --git a/cmd/waku/server/rest/relay.go b/cmd/waku/server/rest/relay.go index 6132df2c9..da5f2d79c 100644 --- a/cmd/waku/server/rest/relay.go +++ b/cmd/waku/server/rest/relay.go @@ -1,7 +1,6 @@ package rest import ( - "context" "encoding/json" "net/http" "strings" @@ -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 @@ -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) @@ -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) diff --git a/cmd/waku/server/rest/relay_test.go b/cmd/waku/server/rest/relay_test.go index 470b9cbb7..4256530e0 100644 --- a/cmd/waku/server/rest/relay_test.go +++ b/cmd/waku/server/rest/relay_test.go @@ -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) @@ -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) diff --git a/cmd/waku/server/rest/waku_rest.go b/cmd/waku/server/rest/waku_rest.go index f6efbfe85..1b5b5204f 100644 --- a/cmd/waku/server/rest/waku_rest.go +++ b/cmd/waku/server/rest/waku_rest.go @@ -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 }