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:
Matthias Radestock committed 2015-04-04 20:36:48 +01:00
1 parent bcd2a0184c
commit 91ed22a953
2 files changed
+19 -19

No files matched your search

+7 -7
View File
@@ -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
}