cosmetic: consistent terminology in var names

This commit is contained in:
Matthias Radestock committed 2015-04-04 22:18:31 +01:00
1 parent 4ebbdabfa1
commit 8c1015d2a4
2 files changed
+16 -16

No files matched your search

+12 -12
View File
@@ -19,9 +19,9 @@ type GossipData interface {
type Gossip interface { type Gossip interface {
// specific message from one peer to another // specific message from one peer to another
// intermediate peers relay it using unicast topology. // intermediate peers relay it using unicast topology.
GossipUnicast(dstPeerName PeerName, buf []byte) error GossipUnicast(dstPeerName PeerName, msg []byte) error
// send a message to every peer, relayed using broadcast topology. // send a message to every peer, relayed using broadcast topology.
GossipBroadcast(buf []byte) error GossipBroadcast(msg []byte) error
} }
type Gossiper interface { type Gossiper interface {
@@ -29,9 +29,9 @@ type Gossiper interface {
OnGossipBroadcast(msg []byte) error OnGossipBroadcast(msg []byte) error
// return state of everything we know; gets called periodically // return state of everything we know; gets called periodically
Gossip() GossipData Gossip() GossipData
// merge received date into state and return "everything new I've // merge received data into state and return "everything new I've
// just learnt", or nil if nothing in the received data was new // just learnt", or nil if nothing in the received data was new
OnGossip(buf []byte) (GossipData, error) OnGossip(update []byte) (GossipData, error)
} }
// Accumulates GossipData that needs to be sent to one destination, // Accumulates GossipData that needs to be sent to one destination,
@@ -210,31 +210,31 @@ func (c *GossipChannel) sendDown(conn Connection, data GossipData) {
sender.Send(data) sender.Send(data)
} }
func (c *GossipChannel) GossipUnicast(dstPeerName PeerName, buf []byte) error { func (c *GossipChannel) GossipUnicast(dstPeerName PeerName, msg []byte) error {
return c.relayUnicast(dstPeerName, GobEncode(c.hash, c.ourself.Name, dstPeerName, buf)) return c.relayUnicast(dstPeerName, GobEncode(c.hash, c.ourself.Name, dstPeerName, msg))
} }
func (c *GossipChannel) GossipBroadcast(buf []byte) error { func (c *GossipChannel) GossipBroadcast(msg []byte) error {
return c.relayBroadcast(c.ourself.Name, GobEncode(c.hash, c.ourself.Name, buf)) return c.relayBroadcast(c.ourself.Name, GobEncode(c.hash, c.ourself.Name, msg))
} }
func (c *GossipChannel) relayUnicast(dstPeerName PeerName, msg []byte) error { func (c *GossipChannel) relayUnicast(dstPeerName PeerName, buf []byte) error {
if relayPeerName, found := c.ourself.Router.Routes.UnicastAll(dstPeerName); !found { if relayPeerName, found := c.ourself.Router.Routes.UnicastAll(dstPeerName); !found {
c.log("unknown relay destination:", dstPeerName) c.log("unknown relay destination:", dstPeerName)
} else if conn, found := c.ourself.ConnectionTo(relayPeerName); !found { } else if conn, found := c.ourself.ConnectionTo(relayPeerName); !found {
c.log("unable to find connection to relay peer", relayPeerName) c.log("unable to find connection to relay peer", relayPeerName)
} else { } else {
conn.(ProtocolSender).SendProtocolMsg(ProtocolMsg{ProtocolGossipUnicast, msg}) conn.(ProtocolSender).SendProtocolMsg(ProtocolMsg{ProtocolGossipUnicast, buf})
} }
return nil return nil
} }
func (c *GossipChannel) relayBroadcast(srcName PeerName, msg []byte) error { func (c *GossipChannel) relayBroadcast(srcName PeerName, buf []byte) error {
nextHops := c.ourself.Router.Routes.BroadcastAll(srcName) nextHops := c.ourself.Router.Routes.BroadcastAll(srcName)
if len(nextHops) == 0 { if len(nextHops) == 0 {
return nil return nil
} }
protocolMsg := ProtocolMsg{ProtocolGossipBroadcast, msg} protocolMsg := ProtocolMsg{ProtocolGossipBroadcast, buf}
// FIXME a single blocked connection can stall us // FIXME a single blocked connection can stall us
for _, conn := range c.ourself.ConnectionsTo(nextHops) { for _, conn := range c.ourself.ConnectionsTo(nextHops) {
conn.(ProtocolSender).SendProtocolMsg(protocolMsg) conn.(ProtocolSender).SendProtocolMsg(protocolMsg)
+4 -4
View File
@@ -387,8 +387,8 @@ func (router *Router) Gossip() GossipData {
return &TopologyGossipData{peers: router.Peers, update: router.Peers.Names()} return &TopologyGossipData{peers: router.Peers, update: router.Peers.Names()}
} }
func (router *Router) OnGossip(buf []byte) (GossipData, error) { func (router *Router) OnGossip(update []byte) (GossipData, error) {
newUpdate, err := router.applyTopologyUpdate(buf) newUpdate, err := router.applyTopologyUpdate(update)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -398,8 +398,8 @@ func (router *Router) OnGossip(buf []byte) (GossipData, error) {
return &TopologyGossipData{peers: router.Peers, update: newUpdate}, nil return &TopologyGossipData{peers: router.Peers, update: newUpdate}, nil
} }
func (router *Router) applyTopologyUpdate(buf []byte) (PeerNameSet, error) { func (router *Router) applyTopologyUpdate(update []byte) (PeerNameSet, error) {
newUpdate, err := router.Peers.ApplyUpdate(buf) newUpdate, err := router.Peers.ApplyUpdate(update)
if _, ok := err.(UnknownPeerError); err != nil && ok { if _, ok := err.(UnknownPeerError); err != nil && ok {
// That update contained a reference to a peer which wasn't // That update contained a reference to a peer which wasn't
// itself included in the update, and we didn't know about // itself included in the update, and we didn't know about