refactor(ish): generalise an abstraction
LocalPeer.NextBroadcastHops -> ConnectionsTo thus separating the computation of who we want to connect to from obtaining the associated Connections
This commit is contained in:
1 parent
bcd2a0184c
commit
91ed22a953
2 files changed
+19
-19
No files matched your search
+7
-7
@@ -230,13 +230,13 @@ func (c *GossipChannel) relayGossipUnicast(dstPeerName PeerName, msg []byte) err
|
||||
}
|
||||
|
||||
func (c *GossipChannel) relayGossipBroadcast(srcName PeerName, msg []byte) error {
|
||||
if srcPeer, found := c.ourself.Router.Peers.Fetch(srcName); !found {
|
||||
c.log("unable to relay broadcast from unknown peer", srcName)
|
||||
} else {
|
||||
protocolMsg := ProtocolMsg{ProtocolGossipBroadcast, msg}
|
||||
for _, conn := range c.ourself.NextBroadcastHops(srcPeer) {
|
||||
conn.SendProtocolMsg(protocolMsg)
|
||||
}
|
||||
nextHops := c.ourself.Router.Routes.Broadcast(srcName)
|
||||
if len(nextHops) == 0 {
|
||||
return nil
|
||||
}
|
||||
protocolMsg := ProtocolMsg{ProtocolGossipBroadcast, msg}
|
||||
for _, conn := range c.ourself.ConnectionsTo(nextHops) {
|
||||
conn.(ProtocolSender).SendProtocolMsg(protocolMsg)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user