Browse Source

Iterator beginnings.

cl-refactor
Gav Wood 11 years ago
parent
commit
3a9f6b22d3
  1. 14
      libethereum/Trie.h
  2. 11
      test/main.cpp

14
libethereum/Trie.h

@ -191,6 +191,17 @@ public:
void remove(bytesConstRef _key);
// TODO: iterators.
/*class iterator
{
public:
iterator()
{
}
operator++()
private:
std::vector<std::pair<RLP, std::string>> m_lineage;
};*/
private:
RLPStream& streamNode(RLPStream& _s, bytes const& _b);
@ -246,7 +257,6 @@ private:
void insertNode(h256 _h, bytesConstRef _v) { m_db->insert(_h, _v); }
void killNode(h256 _h) { m_db->kill(_h); }
h256 insertNode(bytesConstRef _v) { auto h = sha3(_v); insertNode(h, _v); return h; }
void killNode(RLP const& _d) { if (_d.data().size() >= 32) killNode(sha3(_d.data())); }
@ -371,7 +381,7 @@ template <class DB> bytes GenericTrieDB<DB>::mergeAt(RLP const& _orig, NibbleSli
}
auto sh = _k.shared(k);
// 5 << _k << " sh " << k << " = " << sh << std::endl;
// std::cout << _k << " sh " << k << " = " << sh << std::endl;
if (sh)
// shared stuff - cleve at disagreement.
return mergeAt(RLP(cleve(_orig, sh)), _k, _v);

11
test/main.cpp

@ -229,13 +229,6 @@ int main()
}
};
add("doe", "reindeer");
add("do", "verb");
add("doge", "coin");
m.clear();
d.init();
t.remove("doe"); t.remove("do"); t.remove("doge");
s.clear();
add("dogglesworth", "cat");
add("doe", "reindeer");
remove("dogglesworth");
@ -247,10 +240,10 @@ int main()
remove("doge");
remove("doe");
for (int a = 0; a < 200; ++a)
for (int a = 0; a < 20; ++a)
{
StringMap m;
for (int i = 0; i < 200; ++i)
for (int i = 0; i < 20; ++i)
{
auto k = randomWord();
auto v = toString(i);

Loading…
Cancel
Save