aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
authorGav Wood <i@gavwood.com>2014-01-19 01:15:21 +0800
committerGav Wood <i@gavwood.com>2014-01-19 01:15:21 +0800
commit15c5527c29b1eb3ffe69cc64cbe231f0ed5858d7 (patch)
treef1994c3fc82dbf3794dc261a3c2be4e98b54b2fb /main.cpp
parent7d813c4a841cf7ed65e81cbb63a55552c0a53215 (diff)
downloaddexon-solidity-15c5527c29b1eb3ffe69cc64cbe231f0ed5858d7.tar.gz
dexon-solidity-15c5527c29b1eb3ffe69cc64cbe231f0ed5858d7.tar.zst
dexon-solidity-15c5527c29b1eb3ffe69cc64cbe231f0ed5858d7.zip
TrieDB framework and insertion.
LevelDB overlay and map backends.
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/main.cpp b/main.cpp
index 35f3fc20..bab0d280 100644
--- a/main.cpp
+++ b/main.cpp
@@ -113,6 +113,37 @@ int main()
cout << "SENDER: " << hex << low160(eth::sha3(bytesConstRef(&pubkey).cropped(1))) << endl;
}
*/
+
+ {
+ BasicMap m;
+ GenericTrieDB<BasicMap> t(&m);
+ t.init(); // initialise as empty tree.
+ cout << m;
+ cout << t.root() << endl;
+ cout << hash256(StringMap()) << endl;
+
+ t.insert(string("test"), string("test"));
+ cout << m;
+ cout << t.root() << endl;
+ cout << hash256({{"test", "test"}}) << endl;
+
+ t.insert(string("te"), string("test"));
+ cout << m;
+ cout << t.root() << endl;
+ cout << hash256({{"test", "test"}, {"te", "test"}}) << endl;
+ }
+ {
+ BasicMap m;
+ GenericTrieDB<BasicMap> t(&m);
+ t.init(); // initialise as empty tree.
+ t.insert(string("a"), string("A"));
+ t.insert(string("b"), string("B"));
+ cout << m;
+ cout << t.root() << endl;
+ cout << hash256({{"b", "B"}, {"a", "A"}}) << endl;
+ cout << RLP(rlp256({{"b", "B"}, {"a", "A"}})) << endl;
+ }
+ return 0;
cout << escaped(asString(rlp256({{"b", "B"}, {"a", "A"}})), false) << " == " << RLP(rlp256({{"b", "B"}, {"a", "A"}})) << endl;
cout << escaped(asString(rlp256({{"test", "test"}})), false) << " == " << RLP(rlp256({{"test", "test"}})) << endl;
cout << asHex(rlp256({{"test", "test"}, {"te", "test"}})) << endl;
@@ -204,7 +235,7 @@ int main()
assert(asString(rlp("dog")) == "\x43""dog");
// 2-item list
- RLP twoItemList("\x82\x0f\x43""dog");
+ RLP twoItemList((byte const*)"\x82\x0f\x43""dog", 6);
assert(twoItemList.itemCount() == 2);
assert(twoItemList[0] == 15);
assert(twoItemList[1] == "dog");