From d7c4bc04d30ca842d260b33b94be7903534c5270 Mon Sep 17 00:00:00 2001 From: David Wragg Date: Tue, 19 May 2015 12:12:46 +0100 Subject: [PATCH] Eliminate ConnectionMaker Start method --- router/connection_maker.go | 12 +++++------- router/router.go | 1 - 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/router/connection_maker.go b/router/connection_maker.go index d8e34e55..ffbc3602 100644 --- a/router/connection_maker.go +++ b/router/connection_maker.go @@ -34,18 +34,16 @@ type Target struct { type ConnectionMakerAction func() bool func NewConnectionMaker(ourself *LocalPeer, peers *Peers, port int) *ConnectionMaker { - return &ConnectionMaker{ + actionChan := make(chan ConnectionMakerAction, ChannelSize) + cm := &ConnectionMaker{ ourself: ourself, peers: peers, port: port, cmdLinePeers: make(map[string]*net.TCPAddr), - targets: make(map[string]*Target)} -} - -func (cm *ConnectionMaker) Start() { - actionChan := make(chan ConnectionMakerAction, ChannelSize) - cm.actionChan = actionChan + targets: make(map[string]*Target), + actionChan: actionChan} go cm.queryLoop(actionChan) + return cm } func (cm *ConnectionMaker) InitiateConnection(peer string) error { diff --git a/router/router.go b/router/router.go index 640b1f88..24edf0c8 100644 --- a/router/router.go +++ b/router/router.go @@ -83,7 +83,6 @@ func (router *Router) Start() { po, err = NewPcapO(router.Iface.Name) checkFatal(err) } - router.ConnectionMaker.Start() router.UDPListener = router.listenUDP(router.Port, po) router.listenTCP(router.Port) if pio != nil {