Skip to content

Commit

Permalink
Merge pull request ethereum#107 from ethersphere/network-testing-fram…
Browse files Browse the repository at this point in the history
…ework-kadfix

swarm/network: kad fixes
  • Loading branch information
zelig authored Jun 29, 2017
2 parents 66f96da + c4f33d4 commit 8bb82d8
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions swarm/network/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ func (d *discPeer) handleGetPeersMsg(msg *getPeersMsg) error {
resp := &peersMsg{
Peers: peers,
}
return d.Send(resp)
go d.Send(resp)
return nil
}

// RequestOrder broadcasts to trageted peers a request for peers of a particular
Expand All @@ -212,17 +213,22 @@ func RequestOrder(k Overlay, order, broadcastSize, maxPeers uint8) {
Max: maxPeers,
}
var i uint8
//var err error
var peers []Conn
k.EachConn(nil, 255, func(p OverlayConn, po int, isproxbin bool) bool {
if err := p.(Conn).Send(req); err == nil {
i++
if i >= broadcastSize {
return false
}
peers = append(peers, p.(Conn))
if len(peers) >= int(broadcastSize) {
return false
}
return true
})
log.Info(fmt.Sprintf("requesting bees of PO%03d from %v/%v (each max %v)", order, i, broadcastSize, maxPeers))
go func() {
for _, c := range peers {
if err := c.Send(req); err != nil {
break
}
}
log.Info(fmt.Sprintf("requesting bees of PO%03d from %v/%v (each max %v)", order, i, broadcastSize, maxPeers))
}()
}

func (d *discPeer) seen(p OverlayPeer) bool {
Expand Down

0 comments on commit 8bb82d8

Please sign in to comment.