From ca8421c336d92e2a3991fb036d0ba323b95c1fa2 Mon Sep 17 00:00:00 2001 From: Lewis Marshall Date: Sun, 18 Jun 2017 16:26:36 +0200 Subject: [PATCH] p2p/simulations: Add live node stop events Signed-off-by: Lewis Marshall --- p2p/simulations/network.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/p2p/simulations/network.go b/p2p/simulations/network.go index df08c41bcf..706c77dab2 100644 --- a/p2p/simulations/network.go +++ b/p2p/simulations/network.go @@ -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: