Browse Source

Fixes for FatTrie.

cl-refactor
Gav Wood 10 years ago
parent
commit
3e471f8904
  1. 11
      libdevcrypto/OverlayDB.cpp
  2. 2
      libdevcrypto/TrieDB.h

11
libdevcrypto/OverlayDB.cpp

@ -53,7 +53,14 @@ void OverlayDB::commit()
m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size()));
}
if (m_auxKey && m_aux.count(m_auxKey))
{
m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey]));
cdebug << "Committing aux: " << m_auxKey;
m_aux.erase(m_auxKey);
cdebug << "Discarding " << keysOf(m_aux);
}
m_auxKey = h256();
m_aux.clear();
m_over.clear();
m_refCount.clear();
}
@ -65,7 +72,9 @@ bytes OverlayDB::lookupAux(h256 _h) const
if (!ret.empty())
return ret;
std::string v;
m_db->Get(m_readOptions, _h.ref(), &v);
m_db->Get(m_readOptions, aux(_h).ref(), &v);
if (v.empty())
cwarn << "Aux not found: " << _h;
return asBytes(v);
}

2
libdevcrypto/TrieDB.h

@ -408,7 +408,7 @@ public:
Super::setRoot(h256(Super::db()->lookupAux(m_secure.root())));
}
h256 root() const { const_cast<FatGenericTrieDB*>(this)->syncRoot(); return m_secure.root(); }
h256 root() const { return m_secure.root(); }
void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); }
void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); }

Loading…
Cancel
Save