refactor: introduce NewGossipChannel

This commit is contained in:
Matthias Radestock committed 2015-06-14 10:09:36 +01:00
1 parent 882ed85d77
commit 3e0d0a1993
1 file changed
+9 -5
+9 -5
View File
@@ -100,9 +100,9 @@ type peerSenders map[PeerName]*GossipSender
type GossipChannel struct {
sync.Mutex
name string
ourself *LocalPeer
routes *Routes
name string
gossiper Gossiper
senders connectionSenders
broadcasters peerSenders
@@ -110,14 +110,18 @@ type GossipChannel struct {
type GossipChannels map[string]*GossipChannel
func (router *Router) NewGossip(channelName string, g Gossiper) Gossip {
channel := &GossipChannel{
ourself: router.Ourself,
routes: router.Routes,
func NewGossipChannel(channelName string, ourself *LocalPeer, routes *Routes, g Gossiper) *GossipChannel {
return &GossipChannel{
name: channelName,
ourself: ourself,
routes: routes,
gossiper: g,
senders: make(connectionSenders),
broadcasters: make(peerSenders)}
}
func (router *Router) NewGossip(channelName string, g Gossiper) Gossip {
channel := NewGossipChannel(channelName, router.Ourself, router.Routes, g)
router.GossipChannels[channelName] = channel
return channel
}