mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-12 23:13:45 +00:00
p2p/simulations: Add live node stop events
Signed-off-by: Lewis Marshall <lewis@lmars.net>
This commit is contained in:
parent
898f0c1b15
commit
ca8421c336
1 changed files with 10 additions and 1 deletions
|
|
@ -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) {
|
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 {
|
for {
|
||||||
select {
|
select {
|
||||||
case event, ok := <-events:
|
case event, ok := <-events:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue