diff --git a/eth/main.cpp b/eth/main.cpp index 73adddf1e..24520d8c4 100644 --- a/eth/main.cpp +++ b/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{"eth"/*, "shh"*/} : set(), 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); diff --git a/libdevcore/Common.h b/libdevcore/Common.h index edd14f4a5..303512e57 100644 --- a/libdevcore/Common.h +++ b/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 }; diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index a9922063a..3127b349a 100644 --- a/libdevcore/FixedHash.h +++ b/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. diff --git a/libdevcore/Guards.h b/libdevcore/Guards.h index 2d3eced32..44d5969e4 100644 --- a/libdevcore/Guards.h +++ b/libdevcore/Guards.h @@ -95,7 +95,7 @@ using SpinGuard = std::lock_guard; * Mutex m; * int d; * ... - * ETH_(m) + * ETH_GUARDED(m) * { * for (auto d = 50; d > 25; --d) * foo(d); diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 2295904cc..054cd1c9b 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -90,6 +90,9 @@ Client::Client(p2p::Host* _extNet, std::shared_ptr _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); diff --git a/libethereum/Client.h b/libethereum/Client.h index 5124f3778..fac54b010 100644 --- a/libethereum/Client.h +++ b/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