Browse Source

ImportRoute struct instead of class

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
e9748677df
  1. 8
      libethereum/BlockChain.cpp
  2. 14
      libethereum/BlockChain.h
  3. 13
      libethereum/Client.cpp

8
libethereum/BlockChain.cpp

@ -326,8 +326,8 @@ tuple<h256s, h256s, bool> BlockChain::sync(BlockQueue& _bq, OverlayDB const& _st
ImportRoute r;
DEV_TIMED_ABOVE(Block import, 500)
r = import(block.verified, _stateDB, ImportRequirements::Default & ~ImportRequirements::ValidNonce & ~ImportRequirements::CheckUncles);
fresh += r.liveBlocks();
dead += r.deadBlocks();
fresh += r.liveBlocks;
dead += r.deadBlocks;
}
catch (dev::eth::UnknownParent)
{
@ -699,8 +699,8 @@ ImportRoute BlockChain::import(VerifiedBlockRef const& _block, OverlayDB const&
dead.push_back(h);
else
fresh.push_back(h);
return ImportRoute(dead, fresh);
}
return ImportRoute{dead, fresh};
};
void BlockChain::clearBlockBlooms(unsigned _begin, unsigned _end)
{

14
libethereum/BlockChain.h

@ -81,17 +81,9 @@ using BlocksHash = std::unordered_map<h256, bytes>;
using TransactionHashes = h256s;
using UncleHashes = h256s;
class ImportRoute
{
public:
ImportRoute() {};
ImportRoute(h256s const& _deadBlocks, h256s const& _liveBlocks): m_deadBlocks(_deadBlocks), m_liveBlocks(_liveBlocks) {};
h256s const& deadBlocks() const { return m_deadBlocks; }
h256s const& liveBlocks() const { return m_liveBlocks; }
private:
h256s m_deadBlocks;
h256s m_liveBlocks;
struct ImportRoute {
h256s deadBlocks;
h256s liveBlocks;
};
enum {

13
libethereum/Client.cpp

@ -614,10 +614,9 @@ bool Client::submitWork(ProofOfWork::Solution const& _solution)
void Client::syncBlockQueue()
{
cwork << "BQ ==> CHAIN ==> STATE";
pair <h256s, h256s> blocks;
tie(blocks.first, blocks.second, m_syncBlockQueue) = m_bc.sync(m_bq, m_stateDB, rand() % 10 + 5);
ImportRoute ir(blocks.second, blocks.first);
if (ir.liveBlocks().empty())
ImportRoute ir;
tie(ir.liveBlocks, ir.deadBlocks, m_syncBlockQueue) = m_bc.sync(m_bq, m_stateDB, rand() % 10 + 5);
if (ir.liveBlocks.empty())
return;
onChainChanged(ir);
}
@ -659,7 +658,7 @@ void Client::syncTransactionQueue()
void Client::onChainChanged(ImportRoute const& _ir)
{
// insert transactions that we are declaring the dead part of the chain
for (auto const& h: _ir.deadBlocks())
for (auto const& h: _ir.deadBlocks)
{
clog(ClientNote) << "Dead block:" << h;
for (auto const& t: m_bc.transactions(h))
@ -670,7 +669,7 @@ void Client::onChainChanged(ImportRoute const& _ir)
}
// remove transactions from m_tq nicely rather than relying on out of date nonce later on.
for (auto const& h: _ir.liveBlocks())
for (auto const& h: _ir.liveBlocks)
{
clog(ClientChat) << "Live block:" << h;
for (auto const& th: m_bc.transactionHashes(h))
@ -684,7 +683,7 @@ void Client::onChainChanged(ImportRoute const& _ir)
h->noteNewBlocks();
h256Hash changeds;
for (auto const& h: _ir.liveBlocks())
for (auto const& h: _ir.liveBlocks)
appendFromNewBlock(h, changeds);
// RESTART MINING

Loading…
Cancel
Save