p2p/simulations: Add live node stop events

Signed-off-by: Lewis Marshall <lewis@lmars.net>
This commit is contained in:
Lewis Marshall 2017-06-18 16:26:36 +02:00
parent 898f0c1b15
commit ca8421c336

View file

@ -337,7 +337,16 @@ func (self *Network) startWithSnapshots(id discover.NodeID, snapshots map[string
}
func (self *Network) watchPeerEvents(id discover.NodeID, events chan *p2p.PeerEvent, sub event.Subscription) {
defer sub.Unsubscribe()
defer func() {
sub.Unsubscribe()
// assume the node is now down
self.lock.Lock()
node := self.getNode(id)
node.Up = false
self.lock.Unlock()
self.events.Send(NewEvent(node))
}()
for {
select {
case event, ok := <-events: