refactor: add a little helper to improve abstraction

This commit is contained in:
Matthias Radestock committed 2015-06-14 11:09:55 +01:00
1 parent cea85eb05b
commit c4c5ec1e92
2 files changed
+6 -1

No files matched your search

+5
View File
@@ -92,6 +92,11 @@ func (router *Router) NewGossip(channelName string, g Gossiper) Gossip {
return channel
}
func (router *Router) gossipChannel(channelName string) (*GossipChannel, bool) {
channel, found := router.GossipChannels[channelName]
return channel, found
}
func (router *Router) SendAllGossip() {
for _, channel := range router.GossipChannels {
if gossip := channel.gossiper.Gossip(); gossip != nil {
+1 -1
View File
@@ -37,7 +37,7 @@ func (router *Router) handleGossip(tag ProtocolTag, payload []byte) error {
if err := decoder.Decode(&channelName); err != nil {
return err
}
channel, found := router.GossipChannels[channelName]
channel, found := router.gossipChannel(channelName)
if !found {
return fmt.Errorf("[gossip] received unknown channel with name %s", channelName)
}