aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGav Wood <i@gavwood.com>2014-10-17 00:43:48 +0800
committerGav Wood <i@gavwood.com>2014-10-17 00:43:48 +0800
commit165e9780f7b79bdead6eb6af7f5a857398159eb2 (patch)
tree87cb03af4af6a10b6160086c6774fe6add8d103d
parentea27fbe5f33e982babf13df25334dccd112dd96b (diff)
downloaddexon-solidity-165e9780f7b79bdead6eb6af7f5a857398159eb2.tar.gz
dexon-solidity-165e9780f7b79bdead6eb6af7f5a857398159eb2.tar.zst
dexon-solidity-165e9780f7b79bdead6eb6af7f5a857398159eb2.zip
Correct namespace for a few things in devcrypto.
Added lower_bound to TrieDB. Added nextActiveAddress to State.
-rw-r--r--MemTrie.cpp4
-rw-r--r--crypto.cpp2
-rw-r--r--hexPrefix.cpp1
-rw-r--r--trie.cpp46
4 files changed, 48 insertions, 5 deletions
diff --git a/MemTrie.cpp b/MemTrie.cpp
index d654179f..4879f267 100644
--- a/MemTrie.cpp
+++ b/MemTrie.cpp
@@ -55,7 +55,7 @@ public:
#endif
/// 256-bit hash of the node - this is a SHA-3/256 hash of the RLP of the node.
- h256 hash256() const { RLPStream s; makeRLP(s); return dev::eth::sha3(s.out()); }
+ h256 hash256() const { RLPStream s; makeRLP(s); return dev::sha3(s.out()); }
bytes rlp() const { RLPStream s; makeRLP(s); return s.out(); }
void mark() { m_hash256 = h256(); }
@@ -200,7 +200,7 @@ void MemTrieNode::putRLP(RLPStream& _parentStream) const
if (s.out().size() < 32)
_parentStream.APPEND_CHILD(s.out());
else
- _parentStream << dev::eth::sha3(s.out());
+ _parentStream << dev::sha3(s.out());
}
void TrieBranchNode::makeRLP(RLPStream& _intoStream) const
diff --git a/crypto.cpp b/crypto.cpp
index 55feb1a5..ebe3f81a 100644
--- a/crypto.cpp
+++ b/crypto.cpp
@@ -150,7 +150,7 @@ int cryptoTest()
int ret = secp256k1_ecdsa_recover_compact((byte const*)hmsg.data(), (int)hmsg.size(), (byte const*)sig64.data(), pubkey.data(), &pubkeylen, 0, (int)t.vrs.v - 27);
pubkey.resize(pubkeylen);
cout << "RECPUB: " << dec << ret << " " << pubkeylen << " " << toHex(pubkey) << endl;
- cout << "SENDER: " << hex << toAddress(dev::eth::sha3(bytesConstRef(&pubkey).cropped(1))) << dec << endl;
+ cout << "SENDER: " << hex << toAddress(dev::sha3(bytesConstRef(&pubkey).cropped(1))) << dec << endl;
}
#endif
return 0;
diff --git a/hexPrefix.cpp b/hexPrefix.cpp
index 6ced839d..fb2fbc82 100644
--- a/hexPrefix.cpp
+++ b/hexPrefix.cpp
@@ -29,7 +29,6 @@
using namespace std;
using namespace dev;
-using namespace dev::eth;
namespace js = json_spirit;
BOOST_AUTO_TEST_CASE(hexPrefix_test)
diff --git a/trie.cpp b/trie.cpp
index fb74ebe2..899eb1f6 100644
--- a/trie.cpp
+++ b/trie.cpp
@@ -31,7 +31,6 @@
using namespace std;
using namespace dev;
-using namespace dev::eth;
namespace js = json_spirit;
@@ -236,6 +235,51 @@ BOOST_AUTO_TEST_CASE(moreTrieTests)
}
}
+BOOST_AUTO_TEST_CASE(trieLowerBound)
+{
+ cnote << "Stress-testing Trie.lower_bound...";
+ {
+ MemoryDB dm;
+ EnforceRefs e(dm, true);
+ GenericTrieDB<MemoryDB> d(&dm);
+ d.init(); // initialise as empty tree.
+ for (int a = 0; a < 20; ++a)
+ {
+ StringMap m;
+ for (int i = 0; i < 50; ++i)
+ {
+ auto k = randomWord();
+ auto v = toString(i);
+ m[k] = v;
+ d.insert(k, v);
+ }
+
+ for (auto i: d)
+ {
+ auto it = d.lower_bound(i.first);
+ for (auto iit = d.begin(); iit != d.end(); ++iit)
+ if ((*iit).first.toString() >= i.first.toString())
+ {
+ BOOST_REQUIRE(it == iit);
+ break;
+ }
+ }
+ for (unsigned i = 0; i < 100; ++i)
+ {
+ auto k = randomWord();
+ auto it = d.lower_bound(k);
+ for (auto iit = d.begin(); iit != d.end(); ++iit)
+ if ((*iit).first.toString() >= k)
+ {
+ BOOST_REQUIRE(it == iit);
+ break;
+ }
+ }
+
+ }
+ }
+}
+
BOOST_AUTO_TEST_CASE(trieStess)
{
cnote << "Stress-testing Trie...";