diff options
author | Gav Wood <i@gavwood.com> | 2014-01-19 01:15:21 +0800 |
---|---|---|
committer | Gav Wood <i@gavwood.com> | 2014-01-19 01:15:21 +0800 |
commit | 15c5527c29b1eb3ffe69cc64cbe231f0ed5858d7 (patch) | |
tree | f1994c3fc82dbf3794dc261a3c2be4e98b54b2fb /main.cpp | |
parent | 7d813c4a841cf7ed65e81cbb63a55552c0a53215 (diff) | |
download | dexon-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.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
@@ -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"); |