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. 5
      libethereum/EthereumHost.cpp
  5. 4
      libethereum/State.cpp

2
alethzero/MainWin.h

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

6
libethereum/BlockQueue.h

@ -23,7 +23,8 @@
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <libdevcore/Common.h> #include <libdevcore/Common.h>
#include "libethcore/CommonEth.h" #include <libdevcore/Log.h>
#include <libethcore/CommonEth.h>
#include <libdevcore/Guards.h> #include <libdevcore/Guards.h>
namespace dev namespace dev
@ -33,6 +34,9 @@ namespace eth
class BlockChain; 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. * @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). * Sorts them ready for blockchain insertion (with the BlockChain::sync() method).

5
libethereum/EthereumHost.cpp

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

4
libethereum/State.cpp

@ -315,18 +315,16 @@ bool State::sync(BlockChain const& _bc, h256 _block, BlockInfo const& _bi)
bool ret = false; bool ret = false;
// BLOCK // BLOCK
BlockInfo bi = _bi; BlockInfo bi = _bi;
if (!bi)
while (1) while (1)
{ {
try try
{
if (!bi)
{ {
auto b = _bc.block(_block); auto b = _bc.block(_block);
bi.populate(b); bi.populate(b);
// bi.verifyInternals(_bc.block(_block)); // Unneeded - we already verify on import into the blockchain. // bi.verifyInternals(_bc.block(_block)); // Unneeded - we already verify on import into the blockchain.
break; break;
} }
}
catch (Exception const& _e) catch (Exception const& _e)
{ {
// TODO: Slightly nicer handling? :-) // TODO: Slightly nicer handling? :-)

Loading…
Cancel
Save