From 6f0c687d25438848b2dbbc11010cd9a6a3dc044b Mon Sep 17 00:00:00 2001 From: alok Date: Tue, 3 Oct 2023 13:11:40 +0530 Subject: [PATCH] fix: broadcast to older peers --- pkg/topology/topology.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/topology/topology.go b/pkg/topology/topology.go index 632c31f8..7bf9c878 100644 --- a/pkg/topology/topology.go +++ b/pkg/topology/topology.go @@ -77,6 +77,28 @@ func (t *topology) Connected(p p2p.Peer) { if err != nil { t.logger.Error("failed to broadcast peers", "err", err, "peer", p) } + + if p.Type == p2p.PeerTypeBuilder { + // If the peer is a builder, we want to broadcast to the searcher peers + peersToBroadcastTo := t.GetPeers(Query{Type: p2p.PeerTypeSearcher}) + builderUnderlay, err := t.addressbook.GetPeerInfo(p) + if err != nil { + t.logger.Error("failed to get peer info", "err", err, "peer", p) + return + } + for _, peer := range peersToBroadcastTo { + err := t.announcer.BroadcastPeers(context.Background(), peer, []p2p.PeerInfo{ + { + EthAddress: p.EthAddress, + Underlay: builderUnderlay, + }, + }) + if err != nil { + t.logger.Error("failed to broadcast peer", "err", err, "peer", peer) + continue + } + } + } } }