diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-30 22:58:31 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-30 22:58:31 +0800 |
commit | 6b7dfa1fb5279407177fb9fb6574ad9760a4e307 (patch) | |
tree | 7c8aca5aaf4355256bf245543842065073e56771 /peer.go | |
parent | 2ef3a989298aa8dca7872be07ad0abbc32728cc7 (diff) | |
parent | 17c825f53a2676ffe17fd7731f8f550aebcb56b0 (diff) | |
download | dexon-6b7dfa1fb5279407177fb9fb6574ad9760a4e307.tar dexon-6b7dfa1fb5279407177fb9fb6574ad9760a4e307.tar.gz dexon-6b7dfa1fb5279407177fb9fb6574ad9760a4e307.tar.bz2 dexon-6b7dfa1fb5279407177fb9fb6574ad9760a4e307.tar.lz dexon-6b7dfa1fb5279407177fb9fb6574ad9760a4e307.tar.xz dexon-6b7dfa1fb5279407177fb9fb6574ad9760a4e307.tar.zst dexon-6b7dfa1fb5279407177fb9fb6574ad9760a4e307.zip |
Merge branch 'develop'
Diffstat (limited to 'peer.go')
-rw-r--r-- | peer.go | 19 |
1 files changed, 7 insertions, 12 deletions
@@ -2,7 +2,6 @@ package eth import ( "bytes" - "container/list" "fmt" "github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethutil" @@ -440,7 +439,7 @@ func (p *Peer) HandleInbound() { ethutil.Config.Log.Debugf("[PEER] Found canonical block, returning chain from: %x ", parent.Hash()) chain := p.ethereum.BlockChain().GetChainFromHash(parent.Hash(), amountOfBlocks) if len(chain) > 0 { - ethutil.Config.Log.Debugf("[PEER] Returning %d blocks: %x ", len(chain), parent.Hash()) + //ethutil.Config.Log.Debugf("[PEER] Returning %d blocks: %x ", len(chain), parent.Hash()) p.QueueMessage(ethwire.NewMessage(ethwire.MsgBlockTy, chain)) } else { p.QueueMessage(ethwire.NewMessage(ethwire.MsgBlockTy, []interface{}{})) @@ -450,9 +449,11 @@ func (p *Peer) HandleInbound() { //ethutil.Config.Log.Debugf("[PEER] Could not find a similar block") // If no blocks are found we send back a reply with msg not in chain // and the last hash from get chain - lastHash := msg.Data.Get(l - 1) - //log.Printf("Sending not in chain with hash %x\n", lastHash.AsRaw()) - p.QueueMessage(ethwire.NewMessage(ethwire.MsgNotInChainTy, []interface{}{lastHash.Raw()})) + if l > 0 { + lastHash := msg.Data.Get(l - 1) + //log.Printf("Sending not in chain with hash %x\n", lastHash.AsRaw()) + p.QueueMessage(ethwire.NewMessage(ethwire.MsgNotInChainTy, []interface{}{lastHash.Raw()})) + } } case ethwire.MsgNotInChainTy: ethutil.Config.Log.Debugf("Not in chain: %x\n", msg.Data.Get(0).Bytes()) @@ -521,13 +522,7 @@ func (p *Peer) Stop() { } // Pre-emptively remove the peer; don't wait for reaping. We already know it's dead if we are here - p.ethereum.peerMut.Lock() - defer p.ethereum.peerMut.Unlock() - eachPeer(p.ethereum.peers, func(peer *Peer, e *list.Element) { - if peer == p { - p.ethereum.peers.Remove(e) - } - }) + p.ethereum.RemovePeer(p) } func (p *Peer) pushHandshake() error { |