Browse Source

Fixes for state getting.

cl-refactor
Gav Wood 10 years ago
parent
commit
d25224822e
  1. 2
      alethzero/MainWin.h
  2. 6
      libethereum/BlockQueue.cpp
  3. 6
      libethereum/BlockQueue.h
  4. 7
      libethereum/EthereumHost.cpp
  5. 32
      libethereum/State.cpp

2
alethzero/MainWin.h

@ -69,7 +69,7 @@ public:
explicit Main(QWidget *parent = 0);
~Main();
dev::eth::Client* client() { return m_client.get(); }
dev::eth::Client* client() const { return m_client.get(); }
QList<dev::KeyPair> const& owned() const { return m_myKeys; }

6
libethereum/BlockQueue.cpp

@ -34,14 +34,14 @@ bool BlockQueue::import(bytesConstRef _block, BlockChain const& _bc)
// Check if we already know this block.
h256 h = BlockInfo::headerHash(_block);
cnote << "Queuing block" << h.abridged() << "for import...";
cblockq << "Queuing block" << h.abridged() << "for import...";
UpgradableGuard l(m_lock);
if (m_readySet.count(h) || m_drainingSet.count(h) || m_unknownSet.count(h))
{
// Already know about this one.
cnote << "Already known.";
cblockq << "Already known.";
return false;
}
@ -66,7 +66,7 @@ bool BlockQueue::import(bytesConstRef _block, BlockChain const& _bc)
// Check block doesn't already exist first!
if (_bc.details(h))
{
cnote << "Already known in chain.";
cblockq << "Already known in chain.";
return false;
}

6
libethereum/BlockQueue.h

@ -23,7 +23,8 @@
#include <boost/thread.hpp>
#include <libdevcore/Common.h>
#include "libethcore/CommonEth.h"
#include <libdevcore/Log.h>
#include <libethcore/CommonEth.h>
#include <libdevcore/Guards.h>
namespace dev
@ -33,6 +34,9 @@ namespace eth
class BlockChain;
struct BlockQueueChannel: public LogChannel { static const char* name() { return "[]Q"; } static const int verbosity = 7; };
#define cblockq dev::LogOutputStream<dev::eth::BlockQueueChannel, true>()
/**
* @brief A queue of blocks. Sits between network or other I/O and the BlockChain.
* Sorts them ready for blockchain insertion (with the BlockChain::sync() method).

7
libethereum/EthereumHost.cpp

@ -97,7 +97,10 @@ void EthereumHost::noteDoneBlocks()
if (m_blocksOnWay.empty())
{
// Done our chain-get.
clog(NetNote) << "No more blocks coming. Missing" << m_blocksNeeded.size() << "blocks.";
if (m_blocksNeeded.size())
clog(NetNote) << "No more blocks coming. Missing" << m_blocksNeeded.size() << "blocks.";
else
clog(NetNote) << "No more blocks to get.";
m_latestBlockSent = m_chain->currentHash();
}
}
@ -192,7 +195,7 @@ void EthereumHost::maintainBlocks(BlockQueue& _bq, h256 _currentHash)
bs += m_chain->block(h);
++c;
}
clog(NetNote) << "Sending" << c << "new blocks (current is" << _currentHash << ", was" << m_latestBlockSent << ")";
clog(NetMessageSummary) << "Sending" << c << "new blocks (current is" << _currentHash << ", was" << m_latestBlockSent << ")";
ts.appendList(1 + c).append(BlocksPacket).appendRaw(bs, c);
bytes b;
ts.swapOut(b);

32
libethereum/State.cpp

@ -315,31 +315,29 @@ bool State::sync(BlockChain const& _bc, h256 _block, BlockInfo const& _bi)
bool ret = false;
// BLOCK
BlockInfo bi = _bi;
while (1)
{
try
if (!bi)
while (1)
{
if (!bi)
try
{
auto b = _bc.block(_block);
bi.populate(b);
// bi.verifyInternals(_bc.block(_block)); // Unneeded - we already verify on import into the blockchain.
break;
}
catch (Exception const& _e)
{
// TODO: Slightly nicer handling? :-)
cerr << "ERROR: Corrupt block-chain! Delete your block-chain DB and restart." << endl;
cerr << _e.description() << endl;
}
catch (std::exception const& _e)
{
// TODO: Slightly nicer handling? :-)
cerr << "ERROR: Corrupt block-chain! Delete your block-chain DB and restart." << endl;
cerr << _e.what() << endl;
}
}
catch (Exception const& _e)
{
// TODO: Slightly nicer handling? :-)
cerr << "ERROR: Corrupt block-chain! Delete your block-chain DB and restart." << endl;
cerr << _e.description() << endl;
}
catch (std::exception const& _e)
{
// TODO: Slightly nicer handling? :-)
cerr << "ERROR: Corrupt block-chain! Delete your block-chain DB and restart." << endl;
cerr << _e.what() << endl;
}
}
if (bi == m_currentBlock)
{
// We mined the last block.

Loading…
Cancel
Save