diff --git a/libethereum/Common.h b/libethereum/Common.h index ec69288ee..01918dea0 100644 --- a/libethereum/Common.h +++ b/libethereum/Common.h @@ -65,7 +65,7 @@ class FixedHash using Arith = boost::multiprecision::number>; public: - static const unsigned size = _N; + enum { size = _N }; FixedHash() { m_data.fill(0); } FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } diff --git a/libethereum/State.h b/libethereum/State.h index 4ea93c1a4..9ed967c4e 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -154,8 +154,11 @@ private: /// Sets m_currentBlock to a clean state, (i.e. no change from m_previousBlock). void resetCurrent(); - void mergeOverlay() { for (auto const& i: m_over) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); m_over.clear(); } - void dropOverlay() { m_over.clear(); } + /// Commit all pending state modifications for archival. This cannot be undone. + void commit() { for (auto const& i: m_over) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); m_over.clear(); } + + /// Rollback all pending state modifictions. + void rollback() { m_over.clear(); } ldb::DB* m_db; ///< The DB, holding all of our Tries' backend data. ldb::WriteOptions m_writeOptions; diff --git a/libethereum/Trie.h b/libethereum/Trie.h index b03bca15c..fa632ac7f 100644 --- a/libethereum/Trie.h +++ b/libethereum/Trie.h @@ -86,6 +86,8 @@ public: private: std::string node(h256 _h) const { if (_h == c_null) return std::string(); if (m_over) { auto it = m_over->find(_h); if (it != m_over->end()) return it->second; } std::string ret; m_db->Get(m_readOptions, ldb::Slice((char const*)&m_root, 32), &ret); return ret; } + void insertNode(h256 _h, bytesConstRef _v) const {} + void killNode(h256 _h) const {} // only from overlay - no killing from DB proper. static const h256 c_null; h256 m_root = c_null; diff --git a/libethereum/vector_ref.h b/libethereum/vector_ref.h index e68dac999..facc5621e 100644 --- a/libethereum/vector_ref.h +++ b/libethereum/vector_ref.h @@ -25,6 +25,7 @@ public: explicit operator bool() const { return m_data && m_count; } + bool contentsEqual(std::vector<_T> const& _c) const { return _c.size() == m_count && !memcmp(_c.data(), m_data, m_count); } std::vector<_T> toVector() const { return std::vector<_T>(m_data, m_data + m_count); } std::string toString() const { return std::string((char const*)m_data, ((char const*)m_data) + m_count); } template operator vector_ref<_T2>() const { assert(m_count * sizeof(_T) / sizeof(_T2) * sizeof(_T2) / sizeof(_T) == m_count); return vector_ref<_T2>((_T2*)m_data, m_count * sizeof(_T) / sizeof(_T2)); }