 |
Ethereum
PoC-8
The C++ Implementation of Ethereum
|
Go to the documentation of this file.
31 return db::Slice(
reinterpret_cast<char const*
>(_h.data()), _h.size);
36 return db::Slice(_str.data(), _str.size());
41 return db::Slice(
reinterpret_cast<char const*
>(&_b[0]), _b.size());
52 auto writeBatch = m_db->createWriteBatch();
58 for (
auto const& i:
m_main)
64 for (
auto const& i:
m_aux)
67 bytes b = i.first.asBytes();
73 for (
unsigned i = 0; i < 10; ++i)
77 m_db->commit(std::move(writeBatch));
80 catch (boost::exception
const& ex)
84 cwarn <<
"Fail writing to state database. Bombing out.";
87 cwarn <<
"Error writing to state database: " << boost::diagnostic_information(ex);
88 cwarn <<
"Sleeping for" << (i + 1) <<
"seconds, then retrying.";
89 std::this_thread::sleep_for(std::chrono::seconds(i + 1));
105 if (!ret.empty() || !m_db)
110 std::string
const v = m_db->lookup(
toSlice(b));
112 cwarn <<
"Aux not found: " << _h;
128 if (!ret.empty() || !m_db)
131 return m_db->lookup(
toSlice(_h));
138 return m_db && m_db->exists(
toSlice(_h));
143 #if ETH_PARANOIA || 1
148 if (!m_db->exists(
toSlice(_h)))
153 cnote <<
"Decreasing DB node ref count below zero with no DB node. Probably "
154 "have a corrupt Trie."
bool exists(h256 const &_h) const
std::string lookup(h256 const &_h) const
bool exists(h256 const &_h) const
bytes lookupAux(h256 const &_h) const
boost::unique_lock< boost::shared_mutex > WriteGuard
std::string lookup(h256 const &_h) const
#define DEV_WRITE_GUARDED(MUTEX)
std::vector< byte > bytes
bool kill(h256 const &_h)
void kill(h256 const &_h)
std::unordered_map< h256, std::pair< bytes, bool > > m_aux
#define DEV_READ_GUARDED(MUTEX)
bytes asBytes(std::string const &_b)
Converts a string to a byte array containing the string's (byte) data.
std::unordered_map< h256, std::pair< std::string, unsigned > > m_main
bytes lookupAux(h256 const &_h) const
db::Slice toSlice(h256 const &_h, unsigned _sub=0)
vector_ref< char const > Slice