Correct namespace for a few things in devcrypto.

Added lower_bound to TrieDB.
Added nextActiveAddress to State.
This commit is contained in:
Gav Wood 2014-10-16 19:43:48 +03:00
parent ea27fbe5f3
commit 165e9780f7
4 changed files with 48 additions and 5 deletions

View File

@ -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

View File

@ -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;

View File

@ -29,7 +29,6 @@
using namespace std;
using namespace dev;
using namespace dev::eth;
namespace js = json_spirit;
BOOST_AUTO_TEST_CASE(hexPrefix_test)

View File

@ -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...";