Eliminate the Routes Start method

This commit is contained in:
David Wragg committed 2015-06-24 17:35:17 +01:00
1 parent 72039bbe5a
commit 8f5d1eec11
3 files changed
+8 -17

No files matched your search

+2 -7
View File
@@ -18,15 +18,10 @@ type mockChannelConnection struct {
dest *Router
}
// Construct a "passive" Router, i.e. without any goroutines, except
// for Routes and GossipSenders.
func NewTestRouter(name string) *Router {
peerName, _ := PeerNameFromString(name)
router := NewRouter(Config{}, peerName, "")
// 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(Config{}, peerName, "nick")
router.Start()
return router
}
-1
View File
@@ -95,7 +95,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 {