Only accept peers if we asked for them

This commit is contained in:
Maran 2014-05-12 16:09:23 +02:00
parent 5fcbaefd0b
commit 8fe0864680
1 changed files with 15 additions and 15 deletions

30
peer.go
View File

@ -401,22 +401,22 @@ func (p *Peer) HandleInbound() {
case ethwire.MsgPeersTy: case ethwire.MsgPeersTy:
// Received a list of peers (probably because MsgGetPeersTy was send) // Received a list of peers (probably because MsgGetPeersTy was send)
// Only act on message if we actually requested for a peers list // Only act on message if we actually requested for a peers list
//if p.requestedPeerList { if p.requestedPeerList {
data := msg.Data data := msg.Data
// Create new list of possible peers for the ethereum to process // Create new list of possible peers for the ethereum to process
peers := make([]string, data.Len()) peers := make([]string, data.Len())
// Parse each possible peer // Parse each possible peer
for i := 0; i < data.Len(); i++ { for i := 0; i < data.Len(); i++ {
value := data.Get(i) value := data.Get(i)
peers[i] = unpackAddr(value.Get(0), value.Get(1).Uint()) peers[i] = unpackAddr(value.Get(0), value.Get(1).Uint())
}
// Connect to the list of peers
p.ethereum.ProcessPeerList(peers)
// Mark unrequested again
p.requestedPeerList = false
} }
// Connect to the list of peers
p.ethereum.ProcessPeerList(peers)
// Mark unrequested again
p.requestedPeerList = false
//}
case ethwire.MsgGetChainTy: case ethwire.MsgGetChainTy:
var parent *ethchain.Block var parent *ethchain.Block
// Length minus one since the very last element in the array is a count // Length minus one since the very last element in the array is a count