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 { type GossipChannel struct {
sync.Mutex sync.Mutex
name string
ourself *LocalPeer ourself *LocalPeer
routes *Routes routes *Routes
name string
gossiper Gossiper gossiper Gossiper
senders connectionSenders senders connectionSenders
broadcasters peerSenders broadcasters peerSenders
@@ -110,14 +110,18 @@ type GossipChannel struct {
type GossipChannels map[string]*GossipChannel type GossipChannels map[string]*GossipChannel
func (router *Router) NewGossip(channelName string, g Gossiper) Gossip { func NewGossipChannel(channelName string, ourself *LocalPeer, routes *Routes, g Gossiper) *GossipChannel {
channel := &GossipChannel{ return &GossipChannel{
ourself: router.Ourself,
routes: router.Routes,
name: channelName, name: channelName,
ourself: ourself,
routes: routes,
gossiper: g, gossiper: g,
senders: make(connectionSenders), senders: make(connectionSenders),
broadcasters: make(peerSenders)} broadcasters: make(peerSenders)}
}
func (router *Router) NewGossip(channelName string, g Gossiper) Gossip {
channel := NewGossipChannel(channelName, router.Ourself, router.Routes, g)
router.GossipChannels[channelName] = channel router.GossipChannels[channelName] = channel
return channel return channel
} }