Browse Source

Fix for invariant macro.

Minor cleanups.
Fix for rescue mode.
cl-refactor
Gav Wood 10 years ago
parent
commit
778e6ff677
  1. 19
      eth/main.cpp
  2. 3
      libdevcore/Common.h
  3. 2
      libdevcore/FixedHash.h
  4. 2
      libdevcore/Guards.h
  5. 3
      libethereum/Client.cpp
  6. 2
      libethereum/Client.h

19
eth/main.cpp

@ -266,8 +266,7 @@ enum class OperationMode
{
Node,
Import,
Export,
Rescue
Export
};
enum class Format
@ -1085,7 +1084,7 @@ int main(int argc, char** argv)
#endif
string jsonAdmin;
bool upnp = true;
WithExisting killChain = WithExisting::Trust;
WithExisting withExisting = WithExisting::Trust;
bool jit = false;
string sentinel;
@ -1252,11 +1251,11 @@ int main(int argc, char** argv)
return -1;
}
else if (arg == "-K" || arg == "--kill-blockchain" || arg == "--kill")
killChain = WithExisting::Kill;
withExisting = WithExisting::Kill;
else if (arg == "-R" || arg == "--rebuild")
killChain = WithExisting::Verify;
withExisting = WithExisting::Verify;
else if (arg == "-R" || arg == "--rescue")
mode = OperationMode::Rescue;
withExisting = WithExisting::Rescue;
else if ((arg == "-c" || arg == "--client-name") && i + 1 < argc)
{
if (arg == "-c")
@ -1534,7 +1533,7 @@ int main(int argc, char** argv)
dev::WebThreeDirect web3(
WebThreeDirect::composeClientVersion("++eth", clientName),
dbPath,
killChain,
withExisting,
nodeMode == NodeMode::Full ? set<string>{"eth"/*, "shh"*/} : set<string>(),
netPrefs,
&nodesState);
@ -1556,12 +1555,6 @@ int main(int argc, char** argv)
}
};
if (mode == OperationMode::Rescue)
{
web3.ethereum()->rescue();
exit(0);
}
if (mode == OperationMode::Export)
{
ofstream fout(filename, std::ofstream::binary);

3
libdevcore/Common.h

@ -189,7 +189,7 @@ private:
/// Scope guard for invariant check in a class derived from HasInvariants.
#if ETH_DEBUG
#define DEV_INVARIANT_CHECK { ::dev::InvariantChecker __dev_invariantCheck(this, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__); }
#define DEV_INVARIANT_CHECK ::dev::InvariantChecker __dev_invariantCheck(this, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)
#else
#define DEV_INVARIANT_CHECK (void)0;
#endif
@ -240,6 +240,7 @@ enum class WithExisting: int
{
Trust = 0,
Verify,
Rescue,
Kill
};

2
libdevcore/FixedHash.h

@ -106,6 +106,8 @@ public:
FixedHash& operator&=(FixedHash const& _c) { for (unsigned i = 0; i < N; ++i) m_data[i] &= _c.m_data[i]; return *this; }
FixedHash operator&(FixedHash const& _c) const { return FixedHash(*this) &= _c; }
FixedHash operator~() const { FixedHash ret; for (unsigned i = 0; i < N; ++i) ret[i] = ~m_data[i]; return ret; }
// Big-endian increment.
FixedHash& operator++() { for (unsigned i = size; i > 0 && !++m_data[--i]; ) {} return *this; }
/// @returns true if all one-bits in @a _c are set in this object.

2
libdevcore/Guards.h

@ -95,7 +95,7 @@ using SpinGuard = std::lock_guard<SpinLock>;
* Mutex m;
* int d;
* ...
* ETH_(m)
* ETH_GUARDED(m)
* {
* for (auto d = 50; d > 25; --d)
* foo(d);

3
libethereum/Client.cpp

@ -90,6 +90,9 @@ Client::Client(p2p::Host* _extNet, std::shared_ptr<GasPricer> _gp, std::string c
m_preMine(m_stateDB, BaseState::CanonGenesis),
m_postMine(m_stateDB)
{
if (_forceAction == WithExisting::Rescue)
m_bc.rescue(m_stateDB);
m_lastGetWork = std::chrono::system_clock::now() - chrono::seconds(30);
m_tqReady = m_tq.onReady([=](){ this->onTransactionQueueReady(); }); // TODO: should read m_tq->onReady(thisThread, syncTransactionQueue);
m_bqReady = m_bq.onReady([=](){ this->onBlockQueueReady(); }); // TODO: should read m_bq->onReady(thisThread, syncBlockQueue);

2
libethereum/Client.h

@ -219,8 +219,6 @@ public:
void setExtraData(bytes const& _extraData) { m_extraData = _extraData; }
/// Rewind to a prior head.
void rewind(unsigned _n) { m_bc.rewind(_n); }
/// Rescue the chain.
void rescue() { stopWorking(); m_bc.rescue(m_stateDB); }
protected:
/// InterfaceStub methods

Loading…
Cancel
Save