From aae1ea1c3fc15700b1b9cc8baeec877bc4572619 Mon Sep 17 00:00:00 2001 From: Christine Eun Date: Thu, 15 Sep 2022 19:48:57 +0000 Subject: [PATCH] spy: Fixed obsvReqC hanging issue --- node/cmd/spy/spy.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/node/cmd/spy/spy.go b/node/cmd/spy/spy.go index 175dadf5d..cfa1836ba 100644 --- a/node/cmd/spy/spy.go +++ b/node/cmd/spy/spy.go @@ -250,6 +250,9 @@ func runSpy(cmd *cobra.Command, args []string) { // Inbound observations obsvC := make(chan *gossipv1.SignedObservation, 50) + // Inbound observation requests + obsvReqC := make(chan *gossipv1.ObservationRequest, 50) + // Inbound signed VAAs signedInC := make(chan *gossipv1.SignedVAAWithQuorum, 50) @@ -274,6 +277,18 @@ func runSpy(cmd *cobra.Command, args []string) { } }() + // Ignore observation requests + // Note: without this, the whole program hangs on observation requests + go func() { + for { + select { + case <-rootCtx.Done(): + return + case <-obsvReqC: + } + } + }() + // Log signed VAAs go func() { for { @@ -299,7 +314,7 @@ func runSpy(cmd *cobra.Command, args []string) { // Run supervisor. supervisor.New(rootCtx, logger, func(ctx context.Context) error { - if err := supervisor.Run(ctx, "p2p", p2p.Run(obsvC, nil, nil, sendC, signedInC, priv, nil, gst, *p2pPort, *p2pNetworkID, *p2pBootstrap, "", false, rootCtxCancel, nil)); err != nil { + if err := supervisor.Run(ctx, "p2p", p2p.Run(obsvC, obsvReqC, nil, sendC, signedInC, priv, nil, gst, *p2pPort, *p2pNetworkID, *p2pBootstrap, "", false, rootCtxCancel, nil)); err != nil { return err }