Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #32 from primevprotocol/discovery.1
Browse files Browse the repository at this point in the history
fix: broadcast to older peers
  • Loading branch information
aloknerurkar authored Oct 3, 2023
2 parents f074c9c + 6f0c687 commit 76581c2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pkg/topology/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
}

Expand Down

0 comments on commit 76581c2

Please sign in to comment.