Browse Source

Fix peersever.

cl-refactor
Gav Wood 10 years ago
parent
commit
7a23515889
  1. 10
      libethereum/Client.cpp
  2. 33
      libethereum/State.cpp
  3. 10
      libwebthree/Client.h

10
libethereum/Client.cpp

@ -443,10 +443,12 @@ void Client::workNet()
m_net->process(); // must be in guard for now since it uses the blockchain.
// returns h256Set as block hashes, once for each block that has come in/gone out.
cwork << "NET <==> TQ ; CHAIN ==> NET ==> BQ";
m_net->cap<EthereumHost>()->sync(m_tq, m_bq);
cwork << "TQ:" << m_tq.items() << "; BQ:" << m_bq.items();
if (m_net->cap<EthereumHost>())
{
cwork << "NET <==> TQ ; CHAIN ==> NET ==> BQ";
m_net->cap<EthereumHost>()->sync(m_tq, m_bq);
cwork << "TQ:" << m_tq.items() << "; BQ:" << m_bq.items();
}
}
}
this_thread::sleep_for(chrono::milliseconds(1));

33
libethereum/State.cpp

@ -315,22 +315,31 @@ bool State::sync(BlockChain const& _bc, h256 _block, BlockInfo const& _bi)
bool ret = false;
// BLOCK
BlockInfo bi = _bi;
try
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.
if (!bi)
{
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 (...)
{
// TODO: Slightly nicer handling? :-)
cerr << "ERROR: Corrupt block-chain! Delete your block-chain DB and restart." << endl;
exit(1);
}
if (bi == m_currentBlock)
{
// We mined the last block.

10
libwebthree/Client.h

@ -47,6 +47,10 @@ enum class NodeMode
Full
};
namespace eth { class Interface; }
namespace shh { class Interface; }
namespace bzz { class Interface; }
/**
* @brief Main API hub for interfacing with Web 3 components. This doesn't do any local multiplexing, so you can only have one
* running on any given machine for the provided DB path.
@ -60,6 +64,12 @@ public:
/// Destructor.
~RawWebThree();
// The mainline interfaces:
eth::Interface* ethereum() const;
shh::Interface* whisper() const;
bzz::Interface* swarm() const;
// Misc stuff:
void setClientVersion(std::string const& _name) { m_clientVersion = _name; }

Loading…
Cancel
Save