Skip to content

Commit 0537eaf

Browse files
feat: updated subscription to listen messages
1 parent a3f8561 commit 0537eaf

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

rolling-shutter/p2p/floodsubpeerdiscovery/gossippeerdiscovery.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,18 @@ func (pd *FloodsubPeerDiscovery) broadcast() error {
129129
}
130130
return nil
131131
}
132+
133+
func (pd *FloodsubPeerDiscovery) ReadLoop(ctx context.Context, subs *pubsub.Subscription) error {
134+
for {
135+
msg, err := subs.Next(ctx)
136+
if err != nil {
137+
return err
138+
}
139+
140+
if msg.ReceivedFrom == pd.PeerID.ID {
141+
continue
142+
}
143+
144+
log.Info().Msgf("found a floodsub discovery message | %v", err)
145+
}
146+
}

rolling-shutter/p2p/p2p.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ func (p *P2PNode) Run(
147147
runner.Go(func() error {
148148
return p.FloodSubDiscovery.Start(ctx)
149149
})
150+
151+
for _, subs := range p.FloodSubDiscovery.Subscription {
152+
runner.Go(func() error {
153+
return p.FloodSubDiscovery.ReadLoop(ctx, subs)
154+
})
155+
}
150156
}
151157
runner.Go(func() error {
152158
log.Info().Str("namespace", p.config.DiscoveryNamespace).Msg("starting advertizing discovery node")

0 commit comments

Comments
 (0)