27 std::unordered_map<h256, std::string> StateCacheDB::get()
const
32 std::unordered_map<h256, std::string> ret;
33 for (
auto const& i: m_main)
34 if (!m_enforceRefs || i.second.second > 0)
35 ret.insert(make_pair(i.first, i.second.first));
52 std::string StateCacheDB::lookup(
h256 const& _h)
const
57 auto it = m_main.find(_h);
58 if (it != m_main.end())
60 if (!m_enforceRefs || it->second.second > 0)
61 return it->second.first;
63 cwarn <<
"Lookup required for value with refcount == 0. This is probably a critical trie issue" << _h;
68 bool StateCacheDB::exists(
h256 const& _h)
const
73 auto it = m_main.find(_h);
74 if (it != m_main.end() && (!m_enforceRefs || it->second.second > 0))
84 auto it = m_main.find(_h);
85 if (it != m_main.end())
91 m_main[_h] = make_pair(_v.
toString(), 1);
93 cdebug <<
"INST" << _h <<
"=>" << m_main[_h].second;
97 bool StateCacheDB::kill(
h256 const& _h)
102 if (m_main.count(_h))
104 if (m_main[_h].second > 0)
114 cdebug <<
"NOKILL-WAS" << _h;
116 cdebug <<
"KILL" << _h <<
"=>" << m_main[_h].second;
131 auto it = m_aux.find(_h);
132 if (it != m_aux.end() && (!m_enforceRefs || it->second.second))
133 return it->second.first;
137 void StateCacheDB::removeAux(
h256 const& _h)
142 m_aux[_h].second =
false;
150 m_aux[_h] = make_pair(_v.
toBytes(),
true);
153 void StateCacheDB::purge()
159 for (
auto it = m_main.begin(); it != m_main.end(); )
160 if (it->second.second)
163 it = m_main.erase(it);
166 for (
auto it = m_aux.begin(); it != m_aux.end(); )
167 if (it->second.second)
170 it = m_aux.erase(it);
179 for (
auto const& i: m_main)