From eafdc1f8e371fd698da33491a01799393249729a Mon Sep 17 00:00:00 2001 From: Péter Szilágyi Date: Tue, 26 May 2015 14:00:21 +0300 Subject: eth, eth/downloader: surface downloaded block origin, drop on error --- eth/handler.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'eth/handler.go') diff --git a/eth/handler.go b/eth/handler.go index 9117a70de..777a9c7c0 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -92,13 +92,13 @@ func NewProtocolManager(protocolVersion, networkId int, mux *event.TypeMux, txpo return manager } -func (pm *ProtocolManager) removePeer(peer *peer) { +func (pm *ProtocolManager) removePeer(id string) { // Unregister the peer from the downloader - pm.downloader.UnregisterPeer(peer.id) + pm.downloader.UnregisterPeer(id) // Remove the peer from the Ethereum peer set too - glog.V(logger.Detail).Infoln("Removing peer", peer.id) - if err := pm.peers.Unregister(peer.id); err != nil { + glog.V(logger.Detail).Infoln("Removing peer", id) + if err := pm.peers.Unregister(id); err != nil { glog.V(logger.Error).Infoln("Removal failed:", err) } } @@ -148,7 +148,7 @@ func (pm *ProtocolManager) handle(p *peer) error { glog.V(logger.Error).Infoln("Addition failed:", err) return err } - defer pm.removePeer(p) + defer pm.removePeer(p.id) if err := pm.downloader.RegisterPeer(p.id, p.recentHash, p.requestHashes, p.requestBlocks); err != nil { return err @@ -315,7 +315,7 @@ func (self *ProtocolManager) handleMsg(p *peer) error { if _, err := self.chainman.InsertChain(types.Blocks{request.Block}); err != nil { glog.V(logger.Error).Infoln("removed peer (", p.id, ") due to block error") - self.removePeer(p) + self.removePeer(p.id) return nil } -- cgit