Browse Source

don't grab unneeded blocks

cl-refactor
arkpar 10 years ago
parent
commit
96d667baa8
  1. 8
      libethereum/BlockChainSync.cpp
  2. 4
      libethereum/BlockChainSync.h

8
libethereum/BlockChainSync.cpp

@ -402,7 +402,7 @@ void PV60Sync::transition(EthereumPeer* _peer, SyncState _s, bool _force, bool _
clog(NetWarn) << "Bad state: asking for Hashes yet not syncing!"; clog(NetWarn) << "Bad state: asking for Hashes yet not syncing!";
return; return;
} }
if (shouldGrabBlocks()) if (shouldGrabBlocks(_peer))
{ {
clog(NetNote) << "Difficulty of hashchain HIGHER. Grabbing" << m_syncingNeededBlocks.size() << "blocks [latest now" << m_syncingLatestHash << ", was" << host().latestBlockSent() << "]"; clog(NetNote) << "Difficulty of hashchain HIGHER. Grabbing" << m_syncingNeededBlocks.size() << "blocks [latest now" << m_syncingLatestHash << ", was" << host().latestBlockSent() << "]";
downloadMan().resetToChain(m_syncingNeededBlocks); downloadMan().resetToChain(m_syncingNeededBlocks);
@ -504,10 +504,10 @@ bool PV60Sync::isSyncing(EthereumPeer* _peer) const
return m_syncer == _peer; return m_syncer == _peer;
} }
bool PV60Sync::shouldGrabBlocks() const bool PV60Sync::shouldGrabBlocks(EthereumPeer* _peer) const
{ {
auto td = m_syncingTotalDifficulty; auto td = _peer->m_totalDifficulty;
auto lh = m_syncingLatestHash; auto lh = _peer->m_latestHash;
auto ctd = host().chain().details().totalDifficulty; auto ctd = host().chain().details().totalDifficulty;
if (m_syncingNeededBlocks.empty()) if (m_syncingNeededBlocks.empty())

4
libethereum/BlockChainSync.h

@ -174,8 +174,8 @@ private:
/// Do we presently need syncing with this peer? /// Do we presently need syncing with this peer?
bool needsSyncing(EthereumPeer* _peer) const; bool needsSyncing(EthereumPeer* _peer) const;
/// Check whether the session should bother grabbing blocks. /// Check whether the session should bother grabbing blocks from a peer.
bool shouldGrabBlocks() const; bool shouldGrabBlocks(EthereumPeer* _peer) const;
/// Attempt to begin syncing with the peer; first check the peer has a more difficlult chain to download, then start asking for hashes, then move to blocks /// Attempt to begin syncing with the peer; first check the peer has a more difficlult chain to download, then start asking for hashes, then move to blocks
void attemptSync(EthereumPeer* _peer); void attemptSync(EthereumPeer* _peer);

Loading…
Cancel
Save