Browse Source

Merge pull request #2310 from arkpar/bc_fix

Prevent syncing with busy peers
cl-refactor
subtly 10 years ago
parent
commit
c313c04bb1
  1. 5
      libethereum/BlockChainSync.cpp
  2. 2
      libethereum/EthereumPeer.cpp

5
libethereum/BlockChainSync.cpp

@ -534,7 +534,7 @@ bool PV60Sync::shouldGrabBlocks(std::shared_ptr<EthereumPeer> _peer) const
void PV60Sync::attemptSync(std::shared_ptr<EthereumPeer> _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;
@ -649,9 +649,8 @@ void PV60Sync::noteDoneBlocks(std::shared_ptr<EthereumPeer> _peer, bool _clemenc
}
resetSync();
downloadMan().reset();
transition(_peer, SyncState::Idle);
}
_peer->m_sub.doneFetch();
}
}
void PV60Sync::onPeerHashes(std::shared_ptr<EthereumPeer> _peer, h256s const& _hashes)

2
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;

Loading…
Cancel
Save