diff --git a/p2p/pex_reactor.go b/p2p/pex_reactor.go index 1ad1a7284..a9b0bbd80 100644 --- a/p2p/pex_reactor.go +++ b/p2p/pex_reactor.go @@ -201,13 +201,12 @@ func (pexR *PEXReactor) ensurePeers() { // Dial picked addresses for _, item := range toDial.Values() { - picked := item.(*NetAddress) - go func() { + go func(picked *NetAddress) { _, err := pexR.sw.DialPeerWithAddress(picked) if err != nil { pexR.book.MarkAttempt(picked) } - }() + }(item.(*NetAddress)) } } diff --git a/p2p/switch.go b/p2p/switch.go index b7b6aa322..a07c026fc 100644 --- a/p2p/switch.go +++ b/p2p/switch.go @@ -212,10 +212,10 @@ func (sw *Switch) Broadcast(chId byte, msg interface{}) chan bool { successChan := make(chan bool, len(sw.peers.List())) log.Debug("Broadcast", "channel", chId, "msg", msg) for _, peer := range sw.peers.List() { - go func() { + go func(peer *Peer) { success := peer.Send(chId, msg) successChan <- success - }() + }(peer) } return successChan