Browse Source

Fix peersever.

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

4
libethereum/Client.cpp

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

15
libethereum/State.cpp

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

10
libwebthree/Client.h

@ -47,6 +47,10 @@ enum class NodeMode
Full 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 * @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. * running on any given machine for the provided DB path.
@ -60,6 +64,12 @@ public:
/// Destructor. /// Destructor.
~RawWebThree(); ~RawWebThree();
// The mainline interfaces:
eth::Interface* ethereum() const;
shh::Interface* whisper() const;
bzz::Interface* swarm() const;
// Misc stuff: // Misc stuff:
void setClientVersion(std::string const& _name) { m_clientVersion = _name; } void setClientVersion(std::string const& _name) { m_clientVersion = _name; }

Loading…
Cancel
Save