Eliminate the Routes Start method

This commit is contained in:
David Wragg committed 2015-06-12 16:11:32 +01:00
1 parent b1308823d2
commit 32b2bcf01b
3 files changed
+8 -15

No files matched your search

+2 -5
View File
@@ -17,11 +17,8 @@ type mockChannelConnection struct {
// Construct a "passive" Router, i.e. without any goroutines, except
// for Routes and GossipSenders.
func NewTestRouter(name PeerName) *Router {
router := NewRouter(RouterConfig{}, name, "")
// need to create a dummy channel otherwise tests hang on nil
// channels when the Router invoked ConnectionMaker.Refresh
router.ConnectionMaker.actionChan = make(chan ConnectionMakerAction, ChannelSize)
router.Routes.Start()
router := NewRouter(RouterConfig{}, name, "nick")
router.Start()
return router
}
-1
View File
@@ -83,7 +83,6 @@ func (router *Router) Start() {
po, err = NewPcapO(router.Iface.Name)
checkFatal(err)
}
router.Routes.Start()
router.ConnectionMaker.Start()
router.UDPListener = router.listenUDP(router.Port, po)
router.listenTCP(router.Port)
+6 -9
View File
@@ -22,26 +22,23 @@ type Routes struct {
}
func NewRoutes(ourself *LocalPeer, peers *Peers) *Routes {
recalculate := make(chan *struct{}, 1)
wait := make(chan chan struct{})
routes := &Routes{
ourself: ourself,
peers: peers,
unicast: make(map[PeerName]PeerName),
unicastAll: make(map[PeerName]PeerName),
broadcast: make(map[PeerName][]PeerName),
broadcastAll: make(map[PeerName][]PeerName)}
broadcastAll: make(map[PeerName][]PeerName),
recalculate: recalculate,
wait: wait}
routes.unicast[ourself.Name] = UnknownPeerName
routes.unicastAll[ourself.Name] = UnknownPeerName
routes.broadcast[ourself.Name] = []PeerName{}
routes.broadcastAll[ourself.Name] = []PeerName{}
return routes
}
func (routes *Routes) Start() {
recalculate := make(chan *struct{}, 1)
wait := make(chan chan struct{})
routes.recalculate = recalculate
routes.wait = wait
go routes.run(recalculate, wait)
return routes
}
func (routes *Routes) PeerNames() PeerNameSet {