eth/downloader: log after state updates, easier to debug

This commit is contained in:
Péter Szilágyi 2015-06-04 15:10:43 +03:00
parent 28c32d1b1b
commit 24cca2f18d

View File

@ -428,24 +428,22 @@ out:
return err return err
} }
// Peer did deliver, but some blocks were off, penalize // Peer did deliver, but some blocks were off, penalize
glog.V(logger.Detail).Infof("%s: block delivery failed: %v", peer, err)
peer.Demote() peer.Demote()
peer.SetIdle() peer.SetIdle()
glog.V(logger.Detail).Infof("%s: block delivery failed: %v", peer, err)
break break
} }
// If no blocks were delivered, demote the peer (above code is needed to mark the packet done!) // If no blocks were delivered, demote the peer (above code is needed to mark the packet done!)
if len(blockPack.blocks) == 0 { if len(blockPack.blocks) == 0 {
glog.V(logger.Detail).Infof("%s: no blocks delivered", peer)
peer.Demote() peer.Demote()
peer.SetIdle() peer.SetIdle()
glog.V(logger.Detail).Infof("%s: no blocks delivered", peer)
break break
} }
// All was successful, promote the peer // All was successful, promote the peer
if glog.V(logger.Detail) && len(blockPack.blocks) > 0 {
glog.Infof("%s: delivered %d blocks", peer, len(blockPack.blocks))
}
peer.Promote() peer.Promote()
peer.SetIdle() peer.SetIdle()
glog.V(logger.Detail).Infof("%s: delivered %d blocks", peer, len(blockPack.blocks))
} }
case <-ticker.C: case <-ticker.C:
// Check for bad peers. Bad peers may indicate a peer not responding // Check for bad peers. Bad peers may indicate a peer not responding