From 3217e8dd16c5643cf29de8424b99f2bf7bccd606 Mon Sep 17 00:00:00 2001 From: arkpar Date: Sat, 27 Jun 2015 13:36:54 +0200 Subject: [PATCH 1/2] prevent syncing with busy peers & extra logging --- libethereum/BlockChainSync.cpp | 2 +- libethereum/EthereumPeer.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libethereum/BlockChainSync.cpp b/libethereum/BlockChainSync.cpp index da341867a..8a402bb74 100644 --- a/libethereum/BlockChainSync.cpp +++ b/libethereum/BlockChainSync.cpp @@ -534,7 +534,7 @@ bool PV60Sync::shouldGrabBlocks(std::shared_ptr _peer) const void PV60Sync::attemptSync(std::shared_ptr _peer) { - if (m_state != SyncState::Idle) + if (m_state != SyncState::Idle || _peer->m_asking != Asking::Nothing) { clog(NetAllDetail) << "Can't sync with this peer - outstanding asks."; return; diff --git a/libethereum/EthereumPeer.cpp b/libethereum/EthereumPeer.cpp index 30c2bfc9a..88878334c 100644 --- a/libethereum/EthereumPeer.cpp +++ b/libethereum/EthereumPeer.cpp @@ -152,6 +152,8 @@ void EthereumPeer::requestHashes(u256 _number, unsigned _count) void EthereumPeer::requestHashes(h256 const& _lastHash) { + if (m_asking != Asking::Nothing) + clog(NetWarn) << "Asking hashes while requesting " << (m_asking == Asking::Nothing ? "nothing" : m_asking == Asking::State ? "state" : m_asking == Asking::Hashes ? "hashes" : m_asking == Asking::Blocks ? "blocks" : "?"); assert(m_asking == Asking::Nothing); setAsking(Asking::Hashes); RLPStream s; From f634b539fa73288390b3e74ad625693f3b12bd29 Mon Sep 17 00:00:00 2001 From: arkpar Date: Sat, 27 Jun 2015 19:18:22 +0200 Subject: [PATCH 2/2] removed superfluous transition --- libethereum/BlockChainSync.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libethereum/BlockChainSync.cpp b/libethereum/BlockChainSync.cpp index 8a402bb74..63ac620ce 100644 --- a/libethereum/BlockChainSync.cpp +++ b/libethereum/BlockChainSync.cpp @@ -649,9 +649,8 @@ void PV60Sync::noteDoneBlocks(std::shared_ptr _peer, bool _clemenc } resetSync(); downloadMan().reset(); - transition(_peer, SyncState::Idle); - } _peer->m_sub.doneFetch(); + } } void PV60Sync::onPeerHashes(std::shared_ptr _peer, h256s const& _hashes)