From 0ecc0ee02ed3cfe82439809315edd9985f5bd292 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Wed, 30 Dec 2015 12:07:56 +0000 Subject: [PATCH] tiny refactor --- mesh/gossip_channel.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/mesh/gossip_channel.go b/mesh/gossip_channel.go index 086fe6e0..f8343e67 100644 --- a/mesh/gossip_channel.go +++ b/mesh/gossip_channel.go @@ -106,6 +106,14 @@ func (c *GossipChannel) GossipBroadcast(update GossipData) error { return c.relayBroadcast(c.ourself.Name, update) } +func (c *GossipChannel) Send(data GossipData) { + c.relay(c.ourself.Name, data) +} + +func (c *GossipChannel) SendDown(conn Connection, data GossipData) { + c.sendDown([]Connection{conn}, data) +} + func (c *GossipChannel) relayUnicast(dstPeerName PeerName, buf []byte) (err error) { if relayPeerName, found := c.routes.UnicastAll(dstPeerName); !found { err = fmt.Errorf("unknown relay destination: %s", dstPeerName) @@ -175,15 +183,6 @@ func (c *GossipChannel) relay(srcName PeerName, data GossipData) { c.sendDown(c.ourself.ConnectionsTo(c.routes.RandomNeighbours(srcName)), data) } -func (c *GossipChannel) Send(data GossipData) { - c.routes.EnsureRecalculated() - c.sendDown(c.ourself.ConnectionsTo(c.routes.RandomNeighbours(c.ourself.Name)), data) -} - -func (c *GossipChannel) SendDown(conn Connection, data GossipData) { - c.sendDown([]Connection{conn}, data) -} - func (c *GossipChannel) sendDown(conns []Connection, data GossipData) { if len(conns) == 0 { return