Browse Source

Fixed issue #1.

cl-refactor
Gav Wood 11 years ago
parent
commit
0d42219a2e
  1. 2
      libethereum/Common.h
  2. 7
      libethereum/State.h
  3. 2
      libethereum/Trie.h
  4. 1
      libethereum/vector_ref.h

2
libethereum/Common.h

@ -65,7 +65,7 @@ class FixedHash
using Arith = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<_N * 8, _N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>;
public:
static const unsigned size = _N;
enum { size = _N };
FixedHash() { m_data.fill(0); }
FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); }

7
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;

2
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;

1
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 <class _T2> 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)); }

Loading…
Cancel
Save