Moving mdb_val conversion constructor off of uint256_union.
This commit is contained in:
parent
66011a4c54
commit
48e00826e7
14 changed files with 710 additions and 709 deletions
|
@ -263,22 +263,22 @@ TEST (block_store, empty_bootstrap)
|
|||
|
||||
TEST (block_store, one_bootstrap)
|
||||
{
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
auto block1 (std::make_shared <rai::send_block> (0, 1, 2, rai::keypair ().prv, 4, 5));
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
auto block1 (std::make_shared <rai::send_block> (0, 1, 2, rai::keypair ().prv, 4, 5));
|
||||
rai::transaction transaction (store.environment, nullptr, true);
|
||||
store.unchecked_put (transaction, block1->hash (), block1);
|
||||
store.unchecked_put (transaction, block1->hash (), block1);
|
||||
store.flush (transaction);
|
||||
auto begin (store.unchecked_begin (transaction));
|
||||
auto end (store.unchecked_end ());
|
||||
ASSERT_NE (end, begin);
|
||||
auto hash1 (begin->first);
|
||||
ASSERT_EQ (block1->hash (), hash1);
|
||||
auto block2 (rai::deserialize_block (begin->second));
|
||||
ASSERT_EQ (*block1, *block2);
|
||||
++begin;
|
||||
ASSERT_EQ (end, begin);
|
||||
auto begin (store.unchecked_begin (transaction));
|
||||
auto end (store.unchecked_end ());
|
||||
ASSERT_NE (end, begin);
|
||||
auto hash1 (begin->first.uint256 ());
|
||||
ASSERT_EQ (block1->hash (), hash1);
|
||||
auto block2 (rai::deserialize_block (begin->second));
|
||||
ASSERT_EQ (*block1, *block2);
|
||||
++begin;
|
||||
ASSERT_EQ (end, begin);
|
||||
}
|
||||
|
||||
TEST (block_store, unchecked_begin_search)
|
||||
|
@ -293,134 +293,134 @@ TEST (block_store, unchecked_begin_search)
|
|||
|
||||
TEST (block_store, frontier_retrieval)
|
||||
{
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
rai::account account1 (0);
|
||||
rai::account_info info1 (0, 0, 0, 0, 0, 0);
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
rai::account account1 (0);
|
||||
rai::account_info info1 (0, 0, 0, 0, 0, 0);
|
||||
rai::transaction transaction (store.environment, nullptr, true);
|
||||
store.account_put (transaction, account1, info1);
|
||||
rai::account_info info2;
|
||||
store.account_get (transaction, account1, info2);
|
||||
ASSERT_EQ (info1, info2);
|
||||
store.account_put (transaction, account1, info1);
|
||||
rai::account_info info2;
|
||||
store.account_get (transaction, account1, info2);
|
||||
ASSERT_EQ (info1, info2);
|
||||
}
|
||||
|
||||
TEST (block_store, one_account)
|
||||
{
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
rai::account account (0);
|
||||
rai::block_hash hash (0);
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
rai::account account (0);
|
||||
rai::block_hash hash (0);
|
||||
rai::transaction transaction (store.environment, nullptr, true);
|
||||
store.account_put (transaction, account, {hash, account, hash, 42, 100, 200});
|
||||
auto begin (store.latest_begin (transaction));
|
||||
auto end (store.latest_end ());
|
||||
ASSERT_NE (end, begin);
|
||||
ASSERT_EQ (account, begin->first);
|
||||
store.account_put (transaction, account, {hash, account, hash, 42, 100, 200});
|
||||
auto begin (store.latest_begin (transaction));
|
||||
auto end (store.latest_end ());
|
||||
ASSERT_NE (end, begin);
|
||||
ASSERT_EQ (account, begin->first.uint256 ());
|
||||
rai::account_info info (begin->second);
|
||||
ASSERT_EQ (hash, info.head);
|
||||
ASSERT_EQ (42, info.balance.number ());
|
||||
ASSERT_EQ (100, info.modified);
|
||||
ASSERT_EQ (hash, info.head);
|
||||
ASSERT_EQ (42, info.balance.number ());
|
||||
ASSERT_EQ (100, info.modified);
|
||||
ASSERT_EQ (200, info.block_count);
|
||||
++begin;
|
||||
ASSERT_EQ (end, begin);
|
||||
++begin;
|
||||
ASSERT_EQ (end, begin);
|
||||
}
|
||||
|
||||
TEST (block_store, two_block)
|
||||
{
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
rai::open_block block1 (0, 1, 1, rai::keypair ().prv, 0, 0);
|
||||
block1.hashables.account = 1;
|
||||
std::vector <rai::block_hash> hashes;
|
||||
std::vector <rai::open_block> blocks;
|
||||
hashes.push_back (block1.hash ());
|
||||
blocks.push_back (block1);
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
rai::open_block block1 (0, 1, 1, rai::keypair ().prv, 0, 0);
|
||||
block1.hashables.account = 1;
|
||||
std::vector <rai::block_hash> hashes;
|
||||
std::vector <rai::open_block> blocks;
|
||||
hashes.push_back (block1.hash ());
|
||||
blocks.push_back (block1);
|
||||
rai::transaction transaction (store.environment, nullptr, true);
|
||||
store.block_put (transaction, hashes [0], block1);
|
||||
rai::open_block block2 (0, 1, 2, rai::keypair ().prv, 0, 0);
|
||||
hashes.push_back (block2.hash ());
|
||||
blocks.push_back (block2);
|
||||
store.block_put (transaction, hashes [1], block2);
|
||||
store.block_put (transaction, hashes [0], block1);
|
||||
rai::open_block block2 (0, 1, 2, rai::keypair ().prv, 0, 0);
|
||||
hashes.push_back (block2.hash ());
|
||||
blocks.push_back (block2);
|
||||
store.block_put (transaction, hashes [1], block2);
|
||||
ASSERT_TRUE (store.block_exists (transaction, block1.hash ()));
|
||||
ASSERT_TRUE (store.block_exists (transaction, block2.hash ()));
|
||||
}
|
||||
|
||||
TEST (block_store, two_account)
|
||||
{
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
rai::account account1 (1);
|
||||
rai::block_hash hash1 (2);
|
||||
rai::account account2 (3);
|
||||
rai::block_hash hash2 (4);
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
rai::account account1 (1);
|
||||
rai::block_hash hash1 (2);
|
||||
rai::account account2 (3);
|
||||
rai::block_hash hash2 (4);
|
||||
rai::transaction transaction (store.environment, nullptr, true);
|
||||
store.account_put (transaction, account1, {hash1, account1, hash1, 42, 100, 300});
|
||||
store.account_put (transaction, account2, {hash2, account2, hash2, 84, 200, 400});
|
||||
auto begin (store.latest_begin (transaction));
|
||||
auto end (store.latest_end ());
|
||||
ASSERT_NE (end, begin);
|
||||
ASSERT_EQ (account1, begin->first);
|
||||
store.account_put (transaction, account1, {hash1, account1, hash1, 42, 100, 300});
|
||||
store.account_put (transaction, account2, {hash2, account2, hash2, 84, 200, 400});
|
||||
auto begin (store.latest_begin (transaction));
|
||||
auto end (store.latest_end ());
|
||||
ASSERT_NE (end, begin);
|
||||
ASSERT_EQ (account1, begin->first.uint256 ());
|
||||
rai::account_info info1 (begin->second);
|
||||
ASSERT_EQ (hash1, info1.head);
|
||||
ASSERT_EQ (42, info1.balance.number ());
|
||||
ASSERT_EQ (100, info1.modified);
|
||||
ASSERT_EQ (hash1, info1.head);
|
||||
ASSERT_EQ (42, info1.balance.number ());
|
||||
ASSERT_EQ (100, info1.modified);
|
||||
ASSERT_EQ (300, info1.block_count);
|
||||
++begin;
|
||||
ASSERT_NE (end, begin);
|
||||
ASSERT_EQ (account2, begin->first);
|
||||
++begin;
|
||||
ASSERT_NE (end, begin);
|
||||
ASSERT_EQ (account2, begin->first.uint256 ());
|
||||
rai::account_info info2 (begin->second);
|
||||
ASSERT_EQ (hash2, info2.head);
|
||||
ASSERT_EQ (84, info2.balance.number ());
|
||||
ASSERT_EQ (200, info2.modified);
|
||||
ASSERT_EQ (hash2, info2.head);
|
||||
ASSERT_EQ (84, info2.balance.number ());
|
||||
ASSERT_EQ (200, info2.modified);
|
||||
ASSERT_EQ (400, info2.block_count);
|
||||
++begin;
|
||||
ASSERT_EQ (end, begin);
|
||||
++begin;
|
||||
ASSERT_EQ (end, begin);
|
||||
}
|
||||
|
||||
TEST (block_store, latest_find)
|
||||
{
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
rai::account account1 (1);
|
||||
rai::block_hash hash1 (2);
|
||||
rai::account account2 (3);
|
||||
rai::block_hash hash2 (4);
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
rai::account account1 (1);
|
||||
rai::block_hash hash1 (2);
|
||||
rai::account account2 (3);
|
||||
rai::block_hash hash2 (4);
|
||||
rai::transaction transaction (store.environment, nullptr, true);
|
||||
store.account_put (transaction, account1, {hash1, account1, hash1, 100, 0, 300});
|
||||
store.account_put (transaction, account2, {hash2, account2, hash2, 200, 0, 400});
|
||||
auto first (store.latest_begin (transaction));
|
||||
auto second (store.latest_begin (transaction));
|
||||
++second;
|
||||
auto find1 (store.latest_begin (transaction, 1));
|
||||
ASSERT_EQ (first, find1);
|
||||
auto find2 (store.latest_begin (transaction, 3));
|
||||
ASSERT_EQ (second, find2);
|
||||
auto find3 (store.latest_begin (transaction, 2));
|
||||
ASSERT_EQ (second, find3);
|
||||
store.account_put (transaction, account1, {hash1, account1, hash1, 100, 0, 300});
|
||||
store.account_put (transaction, account2, {hash2, account2, hash2, 200, 0, 400});
|
||||
auto first (store.latest_begin (transaction));
|
||||
auto second (store.latest_begin (transaction));
|
||||
++second;
|
||||
auto find1 (store.latest_begin (transaction, 1));
|
||||
ASSERT_EQ (first, find1);
|
||||
auto find2 (store.latest_begin (transaction, 3));
|
||||
ASSERT_EQ (second, find2);
|
||||
auto find3 (store.latest_begin (transaction, 2));
|
||||
ASSERT_EQ (second, find3);
|
||||
}
|
||||
|
||||
TEST (block_store, bad_path)
|
||||
{
|
||||
bool init (false);
|
||||
rai::block_store store (init, boost::filesystem::path ("///"));
|
||||
ASSERT_TRUE (init);
|
||||
bool init (false);
|
||||
rai::block_store store (init, boost::filesystem::path ("///"));
|
||||
ASSERT_TRUE (init);
|
||||
}
|
||||
|
||||
TEST (block_store, DISABLED_already_open) // File can be shared
|
||||
{
|
||||
auto path (rai::unique_path ());
|
||||
boost::filesystem::create_directories (path.parent_path ());
|
||||
std::ofstream file;
|
||||
file.open (path.string ().c_str ());
|
||||
ASSERT_TRUE (file.is_open ());
|
||||
bool init (false);
|
||||
rai::block_store store (init, path);
|
||||
ASSERT_TRUE (init);
|
||||
auto path (rai::unique_path ());
|
||||
boost::filesystem::create_directories (path.parent_path ());
|
||||
std::ofstream file;
|
||||
file.open (path.string ().c_str ());
|
||||
ASSERT_TRUE (file.is_open ());
|
||||
bool init (false);
|
||||
rai::block_store store (init, path);
|
||||
ASSERT_TRUE (init);
|
||||
}
|
||||
|
||||
TEST (block_store, roots)
|
||||
|
@ -440,73 +440,73 @@ TEST (block_store, roots)
|
|||
|
||||
TEST (block_store, pending_exists)
|
||||
{
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
rai::pending_key two (2, 0);
|
||||
rai::pending_info pending;
|
||||
rai::pending_key two (2, 0);
|
||||
rai::pending_info pending;
|
||||
rai::transaction transaction (store.environment, nullptr, true);
|
||||
store.pending_put (transaction, two, pending);
|
||||
rai::pending_key one (1, 0);
|
||||
ASSERT_FALSE (store.pending_exists (transaction, one));
|
||||
store.pending_put (transaction, two, pending);
|
||||
rai::pending_key one (1, 0);
|
||||
ASSERT_FALSE (store.pending_exists (transaction, one));
|
||||
}
|
||||
|
||||
TEST (block_store, latest_exists)
|
||||
{
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
rai::block_hash two (2);
|
||||
rai::account_info info;
|
||||
rai::block_hash two (2);
|
||||
rai::account_info info;
|
||||
rai::transaction transaction (store.environment, nullptr, true);
|
||||
store.account_put (transaction, two, info);
|
||||
rai::block_hash one (1);
|
||||
ASSERT_FALSE (store.account_exists (transaction, one));
|
||||
store.account_put (transaction, two, info);
|
||||
rai::block_hash one (1);
|
||||
ASSERT_FALSE (store.account_exists (transaction, one));
|
||||
}
|
||||
|
||||
TEST (block_store, unsynced)
|
||||
{
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
rai::transaction transaction (store.environment, nullptr, true);
|
||||
ASSERT_EQ (store.unsynced_end (), store.unsynced_begin (transaction));
|
||||
rai::block_hash hash1 (0);
|
||||
ASSERT_FALSE (store.unsynced_exists (transaction, hash1));
|
||||
store.unsynced_put (transaction, hash1);
|
||||
ASSERT_TRUE (store.unsynced_exists (transaction, hash1));
|
||||
ASSERT_NE (store.unsynced_end (), store.unsynced_begin (transaction));
|
||||
ASSERT_EQ (hash1, rai::uint256_union (store.unsynced_begin (transaction)->first));
|
||||
store.unsynced_del (transaction, hash1);
|
||||
ASSERT_FALSE (store.unsynced_exists (transaction, hash1));
|
||||
ASSERT_EQ (store.unsynced_end (), store.unsynced_begin (transaction));
|
||||
ASSERT_EQ (store.unsynced_end (), store.unsynced_begin (transaction));
|
||||
rai::block_hash hash1 (0);
|
||||
ASSERT_FALSE (store.unsynced_exists (transaction, hash1));
|
||||
store.unsynced_put (transaction, hash1);
|
||||
ASSERT_TRUE (store.unsynced_exists (transaction, hash1));
|
||||
ASSERT_NE (store.unsynced_end (), store.unsynced_begin (transaction));
|
||||
ASSERT_EQ (hash1, rai::uint256_union (store.unsynced_begin (transaction)->first.uint256 ()));
|
||||
store.unsynced_del (transaction, hash1);
|
||||
ASSERT_FALSE (store.unsynced_exists (transaction, hash1));
|
||||
ASSERT_EQ (store.unsynced_end (), store.unsynced_begin (transaction));
|
||||
}
|
||||
|
||||
TEST (block_store, unsynced_iteration)
|
||||
{
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
rai::transaction transaction (store.environment, nullptr, true);
|
||||
ASSERT_EQ (store.unsynced_end (), store.unsynced_begin (transaction));
|
||||
rai::block_hash hash1 (1);
|
||||
store.unsynced_put (transaction, hash1);
|
||||
rai::block_hash hash2 (2);
|
||||
store.unsynced_put (transaction, hash2);
|
||||
std::unordered_set <rai::block_hash> hashes;
|
||||
for (auto i (store.unsynced_begin (transaction)), n (store.unsynced_end ()); i != n; ++i)
|
||||
{
|
||||
hashes.insert (rai::uint256_union (i->first));
|
||||
}
|
||||
ASSERT_EQ (2, hashes.size ());
|
||||
ASSERT_TRUE (hashes.find (hash1) != hashes.end ());
|
||||
ASSERT_TRUE (hashes.find (hash2) != hashes.end ());
|
||||
ASSERT_EQ (store.unsynced_end (), store.unsynced_begin (transaction));
|
||||
rai::block_hash hash1 (1);
|
||||
store.unsynced_put (transaction, hash1);
|
||||
rai::block_hash hash2 (2);
|
||||
store.unsynced_put (transaction, hash2);
|
||||
std::unordered_set <rai::block_hash> hashes;
|
||||
for (auto i (store.unsynced_begin (transaction)), n (store.unsynced_end ()); i != n; ++i)
|
||||
{
|
||||
hashes.insert (rai::uint256_union (i->first.uint256 ()));
|
||||
}
|
||||
ASSERT_EQ (2, hashes.size ());
|
||||
ASSERT_TRUE (hashes.find (hash1) != hashes.end ());
|
||||
ASSERT_TRUE (hashes.find (hash2) != hashes.end ());
|
||||
}
|
||||
|
||||
TEST (block_store, large_iteration)
|
||||
{
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
bool init (false);
|
||||
rai::block_store store (init, rai::unique_path ());
|
||||
ASSERT_TRUE (!init);
|
||||
std::unordered_set <rai::account> accounts1;
|
||||
for (auto i (0); i < 1000; ++i)
|
||||
|
@ -522,7 +522,7 @@ TEST (block_store, large_iteration)
|
|||
rai::transaction transaction (store.environment, nullptr, false);
|
||||
for (auto i (store.latest_begin (transaction, 0)), n (store.latest_end ()); i != n; ++i)
|
||||
{
|
||||
rai::account current (i->first);
|
||||
rai::account current (i->first.uint256 ());
|
||||
assert (current.number () > previous.number ());
|
||||
accounts2.insert (current);
|
||||
previous = current;
|
||||
|
|
|
@ -565,7 +565,7 @@ TEST (system, generate_send_existing)
|
|||
|
||||
TEST (system, generate_send_new)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::system system (24000, 1);
|
||||
rai::thread_runner runner (system.service, system.nodes [0]->config.io_threads);
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
{
|
||||
|
@ -577,32 +577,32 @@ TEST (system, generate_send_new)
|
|||
}
|
||||
std::vector <rai::account> accounts;
|
||||
accounts.push_back (rai::test_genesis_key.pub);
|
||||
system.generate_send_new (*system.nodes [0], accounts);
|
||||
system.generate_send_new (*system.nodes [0], accounts);
|
||||
rai::account new_account (0);
|
||||
{
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
|
||||
auto iterator2 (system.wallet (0)->store.begin (transaction));
|
||||
if (rai::uint256_union (iterator2->first) != rai::test_genesis_key.pub)
|
||||
if (iterator2->first.uint256 () != rai::test_genesis_key.pub)
|
||||
{
|
||||
new_account = iterator2->first;
|
||||
new_account = iterator2->first.uint256 ();
|
||||
}
|
||||
++iterator2;
|
||||
ASSERT_NE (system.wallet (0)->store.end (), iterator2);
|
||||
if (rai::uint256_union (iterator2->first) != rai::test_genesis_key.pub)
|
||||
if (iterator2->first.uint256 () != rai::test_genesis_key.pub)
|
||||
{
|
||||
new_account = iterator2->first;
|
||||
new_account = iterator2->first.uint256 ();
|
||||
}
|
||||
++iterator2;
|
||||
ASSERT_EQ (system.wallet (0)->store.end (), iterator2);
|
||||
ASSERT_FALSE (new_account.is_zero ());
|
||||
}
|
||||
auto iterations (0);
|
||||
while (system.nodes [0]->balance (new_account) == 0)
|
||||
{
|
||||
system.poll ();
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
}
|
||||
auto iterations (0);
|
||||
while (system.nodes [0]->balance (new_account) == 0)
|
||||
{
|
||||
system.poll ();
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
}
|
||||
system.stop ();
|
||||
runner.join ();
|
||||
}
|
||||
|
|
|
@ -5,28 +5,28 @@
|
|||
|
||||
TEST (wallet, no_key)
|
||||
{
|
||||
bool init;
|
||||
bool init;
|
||||
rai::mdb_env environment (init, rai::unique_path ());
|
||||
ASSERT_FALSE (init);
|
||||
rai::transaction transaction (environment, nullptr, true);
|
||||
rai::kdf kdf;
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
rai::keypair key1;
|
||||
rai::raw_key prv1;
|
||||
ASSERT_TRUE (wallet.fetch (transaction, key1.pub, prv1));
|
||||
ASSERT_TRUE (wallet.valid_password (transaction));
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
rai::keypair key1;
|
||||
rai::raw_key prv1;
|
||||
ASSERT_TRUE (wallet.fetch (transaction, key1.pub, prv1));
|
||||
ASSERT_TRUE (wallet.valid_password (transaction));
|
||||
}
|
||||
|
||||
TEST (wallet, fetch_locked)
|
||||
{
|
||||
bool init;
|
||||
bool init;
|
||||
rai::mdb_env environment (init, rai::unique_path ());
|
||||
ASSERT_FALSE (init);
|
||||
rai::transaction transaction (environment, nullptr, true);
|
||||
rai::kdf kdf;
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_TRUE (wallet.valid_password (transaction));
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_TRUE (wallet.valid_password (transaction));
|
||||
rai::keypair key1;
|
||||
ASSERT_EQ (key1.pub, wallet.insert_adhoc (transaction, key1.prv));
|
||||
auto key2 (wallet.deterministic_insert (transaction));
|
||||
|
@ -42,65 +42,65 @@ TEST (wallet, fetch_locked)
|
|||
|
||||
TEST (wallet, retrieval)
|
||||
{
|
||||
bool init;
|
||||
bool init;
|
||||
rai::mdb_env environment (init, rai::unique_path ());
|
||||
ASSERT_FALSE (init);
|
||||
rai::transaction transaction (environment, nullptr, true);
|
||||
rai::kdf kdf;
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
rai::keypair key1;
|
||||
ASSERT_TRUE (wallet.valid_password (transaction));
|
||||
wallet.insert_adhoc (transaction, key1.prv);
|
||||
rai::raw_key prv1;
|
||||
ASSERT_FALSE (wallet.fetch (transaction, key1.pub, prv1));
|
||||
ASSERT_TRUE (wallet.valid_password (transaction));
|
||||
ASSERT_EQ (key1.prv, prv1);
|
||||
wallet.password.values [0]->bytes [16] ^= 1;
|
||||
rai::raw_key prv2;
|
||||
ASSERT_TRUE (wallet.fetch (transaction, key1.pub, prv2));
|
||||
ASSERT_FALSE (wallet.valid_password (transaction));
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
rai::keypair key1;
|
||||
ASSERT_TRUE (wallet.valid_password (transaction));
|
||||
wallet.insert_adhoc (transaction, key1.prv);
|
||||
rai::raw_key prv1;
|
||||
ASSERT_FALSE (wallet.fetch (transaction, key1.pub, prv1));
|
||||
ASSERT_TRUE (wallet.valid_password (transaction));
|
||||
ASSERT_EQ (key1.prv, prv1);
|
||||
wallet.password.values [0]->bytes [16] ^= 1;
|
||||
rai::raw_key prv2;
|
||||
ASSERT_TRUE (wallet.fetch (transaction, key1.pub, prv2));
|
||||
ASSERT_FALSE (wallet.valid_password (transaction));
|
||||
}
|
||||
|
||||
TEST (wallet, empty_iteration)
|
||||
{
|
||||
bool init;
|
||||
bool init;
|
||||
rai::mdb_env environment (init, rai::unique_path ());
|
||||
ASSERT_FALSE (init);
|
||||
rai::transaction transaction (environment, nullptr, true);
|
||||
rai::kdf kdf;
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
auto i (wallet.begin (transaction));
|
||||
auto j (wallet.end ());
|
||||
ASSERT_EQ (i, j);
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
auto i (wallet.begin (transaction));
|
||||
auto j (wallet.end ());
|
||||
ASSERT_EQ (i, j);
|
||||
}
|
||||
|
||||
TEST (wallet, one_item_iteration)
|
||||
{
|
||||
bool init;
|
||||
bool init;
|
||||
rai::mdb_env environment (init, rai::unique_path ());
|
||||
ASSERT_FALSE (init);
|
||||
rai::transaction transaction (environment, nullptr, true);
|
||||
rai::kdf kdf;
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
rai::keypair key1;
|
||||
wallet.insert_adhoc (transaction, key1.prv);
|
||||
for (auto i (wallet.begin (transaction)), j (wallet.end ()); i != j; ++i)
|
||||
{
|
||||
ASSERT_EQ (key1.pub, i->first);
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
rai::keypair key1;
|
||||
wallet.insert_adhoc (transaction, key1.prv);
|
||||
for (auto i (wallet.begin (transaction)), j (wallet.end ()); i != j; ++i)
|
||||
{
|
||||
ASSERT_EQ (key1.pub, i->first.uint256 ());
|
||||
rai::raw_key password;
|
||||
wallet.wallet_key (password, transaction);
|
||||
rai::raw_key key;
|
||||
key.decrypt (rai::wallet_value (i->second).key, password, wallet.salt (transaction).owords [0]);
|
||||
ASSERT_EQ (key1.prv, key);
|
||||
}
|
||||
ASSERT_EQ (key1.prv, key);
|
||||
}
|
||||
}
|
||||
|
||||
TEST (wallet, two_item_iteration)
|
||||
{
|
||||
bool init;
|
||||
bool init;
|
||||
rai::mdb_env environment (init, rai::unique_path ());
|
||||
ASSERT_FALSE (init);
|
||||
rai::keypair key1;
|
||||
|
@ -117,7 +117,7 @@ TEST (wallet, two_item_iteration)
|
|||
wallet.insert_adhoc (transaction, key2.prv);
|
||||
for (auto i (wallet.begin (transaction)), j (wallet.end ()); i != j; ++i)
|
||||
{
|
||||
pubs.insert (i->first);
|
||||
pubs.insert (i->first.uint256 ());
|
||||
rai::raw_key password;
|
||||
wallet.wallet_key (password, transaction);
|
||||
rai::raw_key key;
|
||||
|
@ -125,32 +125,32 @@ TEST (wallet, two_item_iteration)
|
|||
prvs.insert (key.data);
|
||||
}
|
||||
}
|
||||
ASSERT_EQ (2, pubs.size ());
|
||||
ASSERT_EQ (2, prvs.size ());
|
||||
ASSERT_NE (pubs.end (), pubs.find (key1.pub));
|
||||
ASSERT_NE (prvs.end (), prvs.find (key1.prv.data));
|
||||
ASSERT_NE (pubs.end (), pubs.find (key2.pub));
|
||||
ASSERT_NE (prvs.end (), prvs.find (key2.prv.data));
|
||||
ASSERT_EQ (2, pubs.size ());
|
||||
ASSERT_EQ (2, prvs.size ());
|
||||
ASSERT_NE (pubs.end (), pubs.find (key1.pub));
|
||||
ASSERT_NE (prvs.end (), prvs.find (key1.prv.data));
|
||||
ASSERT_NE (pubs.end (), pubs.find (key2.pub));
|
||||
ASSERT_NE (prvs.end (), prvs.find (key2.prv.data));
|
||||
}
|
||||
|
||||
TEST (wallet, insufficient_spend_one)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::keypair key1;
|
||||
rai::system system (24000, 1);
|
||||
rai::keypair key1;
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
auto block (system.wallet (0)->send_action (rai::test_genesis_key.pub, key1.pub, 500));
|
||||
ASSERT_NE (nullptr, block);
|
||||
ASSERT_EQ (nullptr, system.wallet (0)->send_action (rai::test_genesis_key.pub, key1.pub, rai::genesis_amount));
|
||||
ASSERT_NE (nullptr, block);
|
||||
ASSERT_EQ (nullptr, system.wallet (0)->send_action (rai::test_genesis_key.pub, key1.pub, rai::genesis_amount));
|
||||
}
|
||||
|
||||
TEST (wallet, spend_all_one)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::block_hash latest1 (system.nodes [0]->latest (rai::test_genesis_key.pub));
|
||||
rai::system system (24000, 1);
|
||||
rai::block_hash latest1 (system.nodes [0]->latest (rai::test_genesis_key.pub));
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
rai::keypair key2;
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (rai::test_genesis_key.pub, key2.pub, std::numeric_limits <rai::uint128_t>::max ()));
|
||||
rai::account_info info2;
|
||||
rai::keypair key2;
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (rai::test_genesis_key.pub, key2.pub, std::numeric_limits <rai::uint128_t>::max ()));
|
||||
rai::account_info info2;
|
||||
{
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
|
||||
system.nodes [0]->store.account_get (transaction, rai::test_genesis_key.pub, info2);
|
||||
|
@ -159,15 +159,15 @@ TEST (wallet, spend_all_one)
|
|||
ASSERT_NE (nullptr, block);
|
||||
ASSERT_EQ (latest1, block->previous ());
|
||||
}
|
||||
ASSERT_TRUE (info2.balance.is_zero ());
|
||||
ASSERT_EQ (0, system.nodes [0]->balance (rai::test_genesis_key.pub));
|
||||
ASSERT_TRUE (info2.balance.is_zero ());
|
||||
ASSERT_EQ (0, system.nodes [0]->balance (rai::test_genesis_key.pub));
|
||||
}
|
||||
|
||||
TEST (wallet, send_async)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::system system (24000, 1);
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
rai::keypair key2;
|
||||
rai::keypair key2;
|
||||
std::thread thread ([&system] ()
|
||||
{
|
||||
auto iterations (0);
|
||||
|
@ -179,7 +179,7 @@ TEST (wallet, send_async)
|
|||
}
|
||||
});
|
||||
bool success (false);
|
||||
system.wallet (0)->send_async (rai::test_genesis_key.pub, key2.pub, std::numeric_limits <rai::uint128_t>::max (), [&success] (std::shared_ptr <rai::block> block_a) { ASSERT_NE (nullptr, block_a); success = true; });
|
||||
system.wallet (0)->send_async (rai::test_genesis_key.pub, key2.pub, std::numeric_limits <rai::uint128_t>::max (), [&success] (std::shared_ptr <rai::block> block_a) { ASSERT_NE (nullptr, block_a); success = true; });
|
||||
thread.join ();
|
||||
ASSERT_TRUE (success);
|
||||
}
|
||||
|
@ -189,11 +189,11 @@ TEST (wallet, spend)
|
|||
rai::system system (24000, 1);
|
||||
rai::block_hash latest1 (system.nodes [0]->latest (rai::test_genesis_key.pub));
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
rai::keypair key2;
|
||||
rai::keypair key2;
|
||||
// Sending from empty accounts should always be an error. Accounts need to be opened with an open block, not a send block.
|
||||
ASSERT_EQ (nullptr, system.wallet (0)->send_action (0, key2.pub, 0));
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (rai::test_genesis_key.pub, key2.pub, std::numeric_limits <rai::uint128_t>::max ()));
|
||||
rai::account_info info2;
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (rai::test_genesis_key.pub, key2.pub, std::numeric_limits <rai::uint128_t>::max ()));
|
||||
rai::account_info info2;
|
||||
{
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
|
||||
system.nodes [0]->store.account_get (transaction, rai::test_genesis_key.pub, info2);
|
||||
|
@ -202,15 +202,15 @@ TEST (wallet, spend)
|
|||
ASSERT_NE (nullptr, block);
|
||||
ASSERT_EQ (latest1, block->previous ());
|
||||
}
|
||||
ASSERT_TRUE (info2.balance.is_zero ());
|
||||
ASSERT_EQ (0, system.nodes [0]->balance (rai::test_genesis_key.pub));
|
||||
ASSERT_TRUE (info2.balance.is_zero ());
|
||||
ASSERT_EQ (0, system.nodes [0]->balance (rai::test_genesis_key.pub));
|
||||
}
|
||||
|
||||
TEST (wallet, change)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
rai::keypair key2;
|
||||
rai::keypair key2;
|
||||
auto block1 (system.nodes [0]->representative (rai::test_genesis_key.pub));
|
||||
ASSERT_FALSE (block1.is_zero ());
|
||||
ASSERT_NE (nullptr, system.wallet (0)->change_action (rai::test_genesis_key.pub, key2.pub));
|
||||
|
@ -221,16 +221,16 @@ TEST (wallet, change)
|
|||
|
||||
TEST (wallet, partial_spend)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::system system (24000, 1);
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
rai::keypair key2;
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (rai::test_genesis_key.pub, key2.pub, 500));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 500, system.nodes [0]->balance (rai::test_genesis_key.pub));
|
||||
rai::keypair key2;
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (rai::test_genesis_key.pub, key2.pub, 500));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 500, system.nodes [0]->balance (rai::test_genesis_key.pub));
|
||||
}
|
||||
|
||||
TEST (wallet, spend_no_previous)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::system system (24000, 1);
|
||||
{
|
||||
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
|
||||
|
@ -242,153 +242,153 @@ TEST (wallet, spend_no_previous)
|
|||
system.wallet (0)->insert_adhoc (key.prv);
|
||||
}
|
||||
}
|
||||
rai::keypair key2;
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (rai::test_genesis_key.pub, key2.pub, 500));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 500, system.nodes [0]->balance (rai::test_genesis_key.pub));
|
||||
rai::keypair key2;
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (rai::test_genesis_key.pub, key2.pub, 500));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 500, system.nodes [0]->balance (rai::test_genesis_key.pub));
|
||||
}
|
||||
|
||||
TEST (wallet, find_none)
|
||||
{
|
||||
bool init;
|
||||
bool init;
|
||||
rai::mdb_env environment (init, rai::unique_path ());
|
||||
ASSERT_FALSE (init);
|
||||
rai::transaction transaction (environment, nullptr, true);
|
||||
rai::kdf kdf;
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
rai::uint256_union account (1000);
|
||||
ASSERT_EQ (wallet.end (), wallet.find (transaction, account));
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
rai::uint256_union account (1000);
|
||||
ASSERT_EQ (wallet.end (), wallet.find (transaction, account));
|
||||
}
|
||||
|
||||
TEST (wallet, find_existing)
|
||||
{
|
||||
bool init;
|
||||
bool init;
|
||||
rai::mdb_env environment (init, rai::unique_path ());
|
||||
ASSERT_FALSE (init);
|
||||
rai::transaction transaction (environment, nullptr, true);
|
||||
rai::kdf kdf;
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
rai::keypair key1;
|
||||
ASSERT_FALSE (wallet.exists (transaction, key1.pub));
|
||||
wallet.insert_adhoc (transaction, key1.prv);
|
||||
ASSERT_TRUE (wallet.exists (transaction, key1.pub));
|
||||
auto existing (wallet.find (transaction, key1.pub));
|
||||
ASSERT_NE (wallet.end (), existing);
|
||||
++existing;
|
||||
ASSERT_EQ (wallet.end (), existing);
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
rai::keypair key1;
|
||||
ASSERT_FALSE (wallet.exists (transaction, key1.pub));
|
||||
wallet.insert_adhoc (transaction, key1.prv);
|
||||
ASSERT_TRUE (wallet.exists (transaction, key1.pub));
|
||||
auto existing (wallet.find (transaction, key1.pub));
|
||||
ASSERT_NE (wallet.end (), existing);
|
||||
++existing;
|
||||
ASSERT_EQ (wallet.end (), existing);
|
||||
}
|
||||
|
||||
TEST (wallet, rekey)
|
||||
{
|
||||
bool init;
|
||||
bool init;
|
||||
rai::mdb_env environment (init, rai::unique_path ());
|
||||
ASSERT_FALSE (init);
|
||||
rai::transaction transaction (environment, nullptr, true);
|
||||
rai::kdf kdf;
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
rai::raw_key password;
|
||||
wallet.password.value (password);
|
||||
ASSERT_TRUE (password.data.is_zero ());
|
||||
ASSERT_FALSE (init);
|
||||
rai::keypair key1;
|
||||
wallet.insert_adhoc (transaction, key1.prv);
|
||||
rai::raw_key prv1;
|
||||
wallet.fetch (transaction, key1.pub, prv1);
|
||||
ASSERT_EQ (key1.prv, prv1);
|
||||
ASSERT_FALSE (wallet.rekey (transaction, "1"));
|
||||
ASSERT_TRUE (password.data.is_zero ());
|
||||
ASSERT_FALSE (init);
|
||||
rai::keypair key1;
|
||||
wallet.insert_adhoc (transaction, key1.prv);
|
||||
rai::raw_key prv1;
|
||||
wallet.fetch (transaction, key1.pub, prv1);
|
||||
ASSERT_EQ (key1.prv, prv1);
|
||||
ASSERT_FALSE (wallet.rekey (transaction, "1"));
|
||||
wallet.password.value (password);
|
||||
rai::raw_key password1;
|
||||
wallet.derive_key (password1, transaction, "1");
|
||||
ASSERT_EQ (password1, password);
|
||||
rai::raw_key prv2;
|
||||
wallet.fetch (transaction, key1.pub, prv2);
|
||||
ASSERT_EQ (key1.prv, prv2);
|
||||
*wallet.password.values [0] = 2;
|
||||
ASSERT_TRUE (wallet.rekey (transaction, "2"));
|
||||
ASSERT_EQ (password1, password);
|
||||
rai::raw_key prv2;
|
||||
wallet.fetch (transaction, key1.pub, prv2);
|
||||
ASSERT_EQ (key1.prv, prv2);
|
||||
*wallet.password.values [0] = 2;
|
||||
ASSERT_TRUE (wallet.rekey (transaction, "2"));
|
||||
}
|
||||
|
||||
TEST (account, encode_zero)
|
||||
{
|
||||
rai::uint256_union number0 (0);
|
||||
std::string str0;
|
||||
number0.encode_account (str0);
|
||||
ASSERT_EQ (64, str0.size ());
|
||||
rai::uint256_union number1;
|
||||
ASSERT_FALSE (number1.decode_account (str0));
|
||||
ASSERT_EQ (number0, number1);
|
||||
rai::uint256_union number0 (0);
|
||||
std::string str0;
|
||||
number0.encode_account (str0);
|
||||
ASSERT_EQ (64, str0.size ());
|
||||
rai::uint256_union number1;
|
||||
ASSERT_FALSE (number1.decode_account (str0));
|
||||
ASSERT_EQ (number0, number1);
|
||||
}
|
||||
|
||||
TEST (account, encode_all)
|
||||
{
|
||||
rai::uint256_union number0;
|
||||
number0.decode_hex ("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
std::string str0;
|
||||
number0.encode_account (str0);
|
||||
ASSERT_EQ (64, str0.size ());
|
||||
rai::uint256_union number1;
|
||||
ASSERT_FALSE (number1.decode_account (str0));
|
||||
ASSERT_EQ (number0, number1);
|
||||
rai::uint256_union number0;
|
||||
number0.decode_hex ("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
std::string str0;
|
||||
number0.encode_account (str0);
|
||||
ASSERT_EQ (64, str0.size ());
|
||||
rai::uint256_union number1;
|
||||
ASSERT_FALSE (number1.decode_account (str0));
|
||||
ASSERT_EQ (number0, number1);
|
||||
}
|
||||
|
||||
TEST (account, encode_fail)
|
||||
{
|
||||
rai::uint256_union number0 (0);
|
||||
std::string str0;
|
||||
number0.encode_account (str0);
|
||||
str0 [16] ^= 1;
|
||||
rai::uint256_union number1;
|
||||
ASSERT_TRUE (number1.decode_account (str0));
|
||||
rai::uint256_union number0 (0);
|
||||
std::string str0;
|
||||
number0.encode_account (str0);
|
||||
str0 [16] ^= 1;
|
||||
rai::uint256_union number1;
|
||||
ASSERT_TRUE (number1.decode_account (str0));
|
||||
}
|
||||
|
||||
TEST (wallet, hash_password)
|
||||
{
|
||||
bool init;
|
||||
bool init;
|
||||
rai::mdb_env environment (init, rai::unique_path ());
|
||||
ASSERT_FALSE (init);
|
||||
rai::transaction transaction (environment, nullptr, true);
|
||||
rai::kdf kdf;
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
rai::raw_key hash1;
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
rai::raw_key hash1;
|
||||
wallet.derive_key (hash1, transaction, "");
|
||||
rai::raw_key hash2;
|
||||
wallet.derive_key (hash2, transaction, "");
|
||||
ASSERT_EQ (hash1, hash2);
|
||||
rai::raw_key hash3;
|
||||
ASSERT_EQ (hash1, hash2);
|
||||
rai::raw_key hash3;
|
||||
wallet.derive_key (hash3, transaction, "a");
|
||||
ASSERT_NE (hash1, hash3);
|
||||
ASSERT_NE (hash1, hash3);
|
||||
}
|
||||
|
||||
TEST (fan, reconstitute)
|
||||
{
|
||||
rai::uint256_union value0 (0);
|
||||
rai::fan fan (value0, 1024);
|
||||
for (auto & i: fan.values)
|
||||
{
|
||||
ASSERT_NE (value0, *i);
|
||||
}
|
||||
rai::raw_key value1;
|
||||
rai::uint256_union value0 (0);
|
||||
rai::fan fan (value0, 1024);
|
||||
for (auto & i: fan.values)
|
||||
{
|
||||
ASSERT_NE (value0, *i);
|
||||
}
|
||||
rai::raw_key value1;
|
||||
fan.value (value1);
|
||||
ASSERT_EQ (value0, value1.data);
|
||||
ASSERT_EQ (value0, value1.data);
|
||||
}
|
||||
|
||||
TEST (fan, change)
|
||||
{
|
||||
rai::raw_key value0;
|
||||
rai::raw_key value0;
|
||||
value0.data = 0;
|
||||
rai::raw_key value1;
|
||||
rai::raw_key value1;
|
||||
value1.data = 1;
|
||||
ASSERT_NE (value0, value1);
|
||||
rai::fan fan (value0.data, 1024);
|
||||
ASSERT_NE (value0, value1);
|
||||
rai::fan fan (value0.data, 1024);
|
||||
ASSERT_EQ (1024, fan.values.size ());
|
||||
rai::raw_key value2;
|
||||
fan.value (value2);
|
||||
ASSERT_EQ (value0, value2);
|
||||
fan.value_set (value1);
|
||||
ASSERT_EQ (value0, value2);
|
||||
fan.value_set (value1);
|
||||
fan.value (value2);
|
||||
ASSERT_EQ (value1, value2);
|
||||
ASSERT_EQ (value1, value2);
|
||||
}
|
||||
|
||||
TEST (wallet, reopen_default_password)
|
||||
|
@ -398,170 +398,170 @@ TEST (wallet, reopen_default_password)
|
|||
rai::transaction transaction (environment, nullptr, true);
|
||||
ASSERT_FALSE (init);
|
||||
rai::kdf kdf;
|
||||
{
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
ASSERT_TRUE (wallet.valid_password (transaction));
|
||||
}
|
||||
{
|
||||
bool init;
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
ASSERT_TRUE (wallet.valid_password (transaction));
|
||||
}
|
||||
{
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
{
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
ASSERT_TRUE (wallet.valid_password (transaction));
|
||||
}
|
||||
{
|
||||
bool init;
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
ASSERT_TRUE (wallet.valid_password (transaction));
|
||||
}
|
||||
{
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
wallet.rekey (transaction, "");
|
||||
ASSERT_TRUE (wallet.valid_password (transaction));
|
||||
}
|
||||
{
|
||||
bool init;
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
ASSERT_FALSE (wallet.valid_password (transaction));
|
||||
wallet.attempt_password (transaction, " ");
|
||||
ASSERT_FALSE (wallet.valid_password (transaction));
|
||||
wallet.attempt_password (transaction, "");
|
||||
ASSERT_TRUE (wallet.valid_password (transaction));
|
||||
}
|
||||
ASSERT_TRUE (wallet.valid_password (transaction));
|
||||
}
|
||||
{
|
||||
bool init;
|
||||
rai::wallet_store wallet (init, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (init);
|
||||
ASSERT_FALSE (wallet.valid_password (transaction));
|
||||
wallet.attempt_password (transaction, " ");
|
||||
ASSERT_FALSE (wallet.valid_password (transaction));
|
||||
wallet.attempt_password (transaction, "");
|
||||
ASSERT_TRUE (wallet.valid_password (transaction));
|
||||
}
|
||||
}
|
||||
|
||||
TEST (wallet, representative)
|
||||
{
|
||||
auto error (false);
|
||||
auto error (false);
|
||||
rai::mdb_env environment (error, rai::unique_path ());
|
||||
ASSERT_FALSE (error);
|
||||
rai::transaction transaction (environment, nullptr, true);
|
||||
rai::kdf kdf;
|
||||
rai::wallet_store wallet (error, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (error);
|
||||
ASSERT_FALSE (wallet.is_representative (transaction));
|
||||
ASSERT_EQ (rai::genesis_account, wallet.representative (transaction));
|
||||
ASSERT_FALSE (wallet.is_representative (transaction));
|
||||
rai::keypair key;
|
||||
wallet.representative_set (transaction, key.pub);
|
||||
ASSERT_FALSE (wallet.is_representative (transaction));
|
||||
ASSERT_EQ (key.pub, wallet.representative (transaction));
|
||||
ASSERT_FALSE (wallet.is_representative (transaction));
|
||||
wallet.insert_adhoc (transaction, key.prv);
|
||||
ASSERT_TRUE (wallet.is_representative (transaction));
|
||||
rai::wallet_store wallet (error, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (error);
|
||||
ASSERT_FALSE (wallet.is_representative (transaction));
|
||||
ASSERT_EQ (rai::genesis_account, wallet.representative (transaction));
|
||||
ASSERT_FALSE (wallet.is_representative (transaction));
|
||||
rai::keypair key;
|
||||
wallet.representative_set (transaction, key.pub);
|
||||
ASSERT_FALSE (wallet.is_representative (transaction));
|
||||
ASSERT_EQ (key.pub, wallet.representative (transaction));
|
||||
ASSERT_FALSE (wallet.is_representative (transaction));
|
||||
wallet.insert_adhoc (transaction, key.prv);
|
||||
ASSERT_TRUE (wallet.is_representative (transaction));
|
||||
}
|
||||
|
||||
TEST (wallet, serialize_json_empty)
|
||||
{
|
||||
auto error (false);
|
||||
auto error (false);
|
||||
rai::mdb_env environment (error, rai::unique_path ());
|
||||
ASSERT_FALSE (error);
|
||||
rai::transaction transaction (environment, nullptr, true);
|
||||
rai::kdf kdf;
|
||||
rai::wallet_store wallet1 (error, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
rai::wallet_store wallet1 (error, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (error);
|
||||
std::string serialized;
|
||||
wallet1.serialize_json (transaction, serialized);
|
||||
rai::wallet_store wallet2 (error, kdf, transaction, rai::genesis_account, 1, "1", serialized);
|
||||
ASSERT_FALSE (error);
|
||||
std::string serialized;
|
||||
wallet1.serialize_json (transaction, serialized);
|
||||
rai::wallet_store wallet2 (error, kdf, transaction, rai::genesis_account, 1, "1", serialized);
|
||||
ASSERT_FALSE (error);
|
||||
rai::raw_key password1;
|
||||
rai::raw_key password2;
|
||||
wallet1.wallet_key (password1, transaction);
|
||||
wallet2.wallet_key (password2, transaction);
|
||||
ASSERT_EQ (password1, password2);
|
||||
ASSERT_EQ (wallet1.salt (transaction), wallet2.salt (transaction));
|
||||
ASSERT_EQ (wallet1.check (transaction), wallet2.check (transaction));
|
||||
ASSERT_EQ (wallet1.representative (transaction), wallet2.representative (transaction));
|
||||
ASSERT_EQ (wallet1.end (), wallet1.begin (transaction));
|
||||
ASSERT_EQ (wallet2.end (), wallet2.begin (transaction));
|
||||
ASSERT_EQ (password1, password2);
|
||||
ASSERT_EQ (wallet1.salt (transaction), wallet2.salt (transaction));
|
||||
ASSERT_EQ (wallet1.check (transaction), wallet2.check (transaction));
|
||||
ASSERT_EQ (wallet1.representative (transaction), wallet2.representative (transaction));
|
||||
ASSERT_EQ (wallet1.end (), wallet1.begin (transaction));
|
||||
ASSERT_EQ (wallet2.end (), wallet2.begin (transaction));
|
||||
}
|
||||
|
||||
TEST (wallet, serialize_json_one)
|
||||
{
|
||||
auto error (false);
|
||||
auto error (false);
|
||||
rai::mdb_env environment (error, rai::unique_path ());
|
||||
ASSERT_FALSE (error);
|
||||
rai::transaction transaction (environment, nullptr, true);
|
||||
rai::kdf kdf;
|
||||
rai::wallet_store wallet1 (error, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
rai::wallet_store wallet1 (error, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (error);
|
||||
rai::keypair key;
|
||||
wallet1.insert_adhoc (transaction, key.prv);
|
||||
std::string serialized;
|
||||
wallet1.serialize_json (transaction, serialized);
|
||||
rai::wallet_store wallet2 (error, kdf, transaction, rai::genesis_account, 1, "1", serialized);
|
||||
ASSERT_FALSE (error);
|
||||
rai::keypair key;
|
||||
wallet1.insert_adhoc (transaction, key.prv);
|
||||
std::string serialized;
|
||||
wallet1.serialize_json (transaction, serialized);
|
||||
rai::wallet_store wallet2 (error, kdf, transaction, rai::genesis_account, 1, "1", serialized);
|
||||
ASSERT_FALSE (error);
|
||||
rai::raw_key password1;
|
||||
rai::raw_key password2;
|
||||
wallet1.wallet_key (password1, transaction);
|
||||
wallet2.wallet_key (password2, transaction);
|
||||
ASSERT_EQ (password1, password2);
|
||||
ASSERT_EQ (wallet1.salt (transaction), wallet2.salt (transaction));
|
||||
ASSERT_EQ (wallet1.check (transaction), wallet2.check (transaction));
|
||||
ASSERT_EQ (wallet1.representative (transaction), wallet2.representative (transaction));
|
||||
ASSERT_TRUE (wallet2.exists (transaction, key.pub));
|
||||
rai::raw_key prv;
|
||||
wallet2.fetch (transaction, key.pub, prv);
|
||||
ASSERT_EQ (key.prv, prv);
|
||||
ASSERT_EQ (password1, password2);
|
||||
ASSERT_EQ (wallet1.salt (transaction), wallet2.salt (transaction));
|
||||
ASSERT_EQ (wallet1.check (transaction), wallet2.check (transaction));
|
||||
ASSERT_EQ (wallet1.representative (transaction), wallet2.representative (transaction));
|
||||
ASSERT_TRUE (wallet2.exists (transaction, key.pub));
|
||||
rai::raw_key prv;
|
||||
wallet2.fetch (transaction, key.pub, prv);
|
||||
ASSERT_EQ (key.prv, prv);
|
||||
}
|
||||
|
||||
TEST (wallet, serialize_json_password)
|
||||
{
|
||||
auto error (false);
|
||||
auto error (false);
|
||||
rai::mdb_env environment (error, rai::unique_path ());
|
||||
ASSERT_FALSE (error);
|
||||
rai::transaction transaction (environment, nullptr, true);
|
||||
rai::kdf kdf;
|
||||
rai::wallet_store wallet1 (error, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
rai::wallet_store wallet1 (error, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (error);
|
||||
rai::keypair key;
|
||||
wallet1.rekey (transaction, "password");
|
||||
wallet1.insert_adhoc (transaction, key.prv);
|
||||
std::string serialized;
|
||||
wallet1.serialize_json (transaction, serialized);
|
||||
rai::wallet_store wallet2 (error, kdf, transaction, rai::genesis_account, 1, "1", serialized);
|
||||
ASSERT_FALSE (error);
|
||||
ASSERT_FALSE (wallet2.valid_password (transaction));
|
||||
ASSERT_FALSE (wallet2.attempt_password (transaction, "password"));
|
||||
ASSERT_TRUE (wallet2.valid_password (transaction));
|
||||
rai::keypair key;
|
||||
wallet1.rekey (transaction, "password");
|
||||
wallet1.insert_adhoc (transaction, key.prv);
|
||||
std::string serialized;
|
||||
wallet1.serialize_json (transaction, serialized);
|
||||
rai::wallet_store wallet2 (error, kdf, transaction, rai::genesis_account, 1, "1", serialized);
|
||||
ASSERT_FALSE (error);
|
||||
ASSERT_FALSE (wallet2.valid_password (transaction));
|
||||
ASSERT_FALSE (wallet2.attempt_password (transaction, "password"));
|
||||
ASSERT_TRUE (wallet2.valid_password (transaction));
|
||||
rai::raw_key password1;
|
||||
rai::raw_key password2;
|
||||
wallet1.wallet_key (password1, transaction);
|
||||
wallet2.wallet_key (password2, transaction);
|
||||
ASSERT_EQ (password1, password2);
|
||||
ASSERT_EQ (wallet1.salt (transaction), wallet2.salt (transaction));
|
||||
ASSERT_EQ (wallet1.check (transaction), wallet2.check (transaction));
|
||||
ASSERT_EQ (wallet1.representative (transaction), wallet2.representative (transaction));
|
||||
ASSERT_TRUE (wallet2.exists (transaction, key.pub));
|
||||
rai::raw_key prv;
|
||||
wallet2.fetch (transaction, key.pub, prv);
|
||||
ASSERT_EQ (key.prv, prv);
|
||||
ASSERT_EQ (password1, password2);
|
||||
ASSERT_EQ (wallet1.salt (transaction), wallet2.salt (transaction));
|
||||
ASSERT_EQ (wallet1.check (transaction), wallet2.check (transaction));
|
||||
ASSERT_EQ (wallet1.representative (transaction), wallet2.representative (transaction));
|
||||
ASSERT_TRUE (wallet2.exists (transaction, key.pub));
|
||||
rai::raw_key prv;
|
||||
wallet2.fetch (transaction, key.pub, prv);
|
||||
ASSERT_EQ (key.prv, prv);
|
||||
}
|
||||
|
||||
TEST (wallet_store, move)
|
||||
{
|
||||
auto error (false);
|
||||
auto error (false);
|
||||
rai::mdb_env environment (error, rai::unique_path ());
|
||||
ASSERT_FALSE (error);
|
||||
rai::transaction transaction (environment, nullptr, true);
|
||||
rai::kdf kdf;
|
||||
rai::wallet_store wallet1 (error, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (error);
|
||||
rai::keypair key1;
|
||||
wallet1.insert_adhoc (transaction, key1.prv);
|
||||
rai::wallet_store wallet2 (error, kdf, transaction, rai::genesis_account, 1, "1");
|
||||
ASSERT_FALSE (error);
|
||||
rai::keypair key2;
|
||||
wallet2.insert_adhoc (transaction, key2.prv);
|
||||
ASSERT_FALSE (wallet1.exists (transaction, key2.pub));
|
||||
ASSERT_TRUE (wallet2.exists (transaction, key2.pub));
|
||||
std::vector <rai::public_key> keys;
|
||||
keys.push_back (key2.pub);
|
||||
ASSERT_FALSE (wallet1.move (transaction, wallet2, keys));
|
||||
ASSERT_TRUE (wallet1.exists (transaction, key2.pub));
|
||||
ASSERT_FALSE (wallet2.exists (transaction, key2.pub));
|
||||
rai::wallet_store wallet1 (error, kdf, transaction, rai::genesis_account, 1, "0");
|
||||
ASSERT_FALSE (error);
|
||||
rai::keypair key1;
|
||||
wallet1.insert_adhoc (transaction, key1.prv);
|
||||
rai::wallet_store wallet2 (error, kdf, transaction, rai::genesis_account, 1, "1");
|
||||
ASSERT_FALSE (error);
|
||||
rai::keypair key2;
|
||||
wallet2.insert_adhoc (transaction, key2.prv);
|
||||
ASSERT_FALSE (wallet1.exists (transaction, key2.pub));
|
||||
ASSERT_TRUE (wallet2.exists (transaction, key2.pub));
|
||||
std::vector <rai::public_key> keys;
|
||||
keys.push_back (key2.pub);
|
||||
ASSERT_FALSE (wallet1.move (transaction, wallet2, keys));
|
||||
ASSERT_TRUE (wallet1.exists (transaction, key2.pub));
|
||||
ASSERT_FALSE (wallet2.exists (transaction, key2.pub));
|
||||
}
|
||||
|
||||
TEST (wallet_store, import)
|
||||
{
|
||||
rai::system system (24000, 2);
|
||||
rai::system system (24000, 2);
|
||||
auto wallet1 (system.wallet (0));
|
||||
auto wallet2 (system.wallet (1));
|
||||
rai::keypair key1;
|
||||
|
@ -576,7 +576,7 @@ TEST (wallet_store, import)
|
|||
|
||||
TEST (wallet_store, fail_import_bad_password)
|
||||
{
|
||||
rai::system system (24000, 2);
|
||||
rai::system system (24000, 2);
|
||||
auto wallet1 (system.wallet (0));
|
||||
auto wallet2 (system.wallet (1));
|
||||
rai::keypair key1;
|
||||
|
@ -590,7 +590,7 @@ TEST (wallet_store, fail_import_bad_password)
|
|||
|
||||
TEST (wallet_store, fail_import_corrupt)
|
||||
{
|
||||
rai::system system (24000, 2);
|
||||
rai::system system (24000, 2);
|
||||
auto wallet1 (system.wallet (1));
|
||||
std::string json;
|
||||
auto error (wallet1->import (json, "1"));
|
||||
|
@ -600,8 +600,8 @@ TEST (wallet_store, fail_import_corrupt)
|
|||
// Test arbitrary work can be generated
|
||||
TEST (wallet, empty_work)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto wallet (system.wallet (0));
|
||||
rai::system system (24000, 1);
|
||||
auto wallet (system.wallet (0));
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, true);
|
||||
ASSERT_FALSE (system.work.work_validate (1, wallet->work_fetch (transaction, 0, 1)));
|
||||
}
|
||||
|
@ -609,9 +609,9 @@ TEST (wallet, empty_work)
|
|||
// Test work is precached when a key is inserted
|
||||
TEST (wallet, work)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto wallet (system.wallet (0));
|
||||
wallet->insert_adhoc (rai::test_genesis_key.prv);
|
||||
rai::system system (24000, 1);
|
||||
auto wallet (system.wallet (0));
|
||||
wallet->insert_adhoc (rai::test_genesis_key.prv);
|
||||
uint64_t work4;
|
||||
rai::uint256_union root1;
|
||||
rai::account account1;
|
||||
|
@ -622,7 +622,7 @@ TEST (wallet, work)
|
|||
work4 = wallet->work_fetch (transaction, account1, root1);
|
||||
}
|
||||
ASSERT_FALSE (system.work.work_validate (root1, work4));
|
||||
uint64_t work3 (0);
|
||||
uint64_t work3 (0);
|
||||
auto iteration (0);
|
||||
while (system.work.work_validate (root1, work3))
|
||||
{
|
||||
|
@ -637,8 +637,8 @@ TEST (wallet, work)
|
|||
|
||||
TEST (wallet, work_generate)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto wallet (system.wallet (0));
|
||||
rai::system system (24000, 1);
|
||||
auto wallet (system.wallet (0));
|
||||
rai::uint128_t amount1 (system.nodes [0]->balance (rai::test_genesis_key.pub));
|
||||
uint64_t work1;
|
||||
wallet->insert_adhoc (rai::test_genesis_key.prv);
|
||||
|
@ -648,24 +648,24 @@ TEST (wallet, work_generate)
|
|||
account1 = system.account (transaction, 0);
|
||||
}
|
||||
rai::keypair key;
|
||||
wallet->send_action (rai::test_genesis_key.pub, key.pub, 100);
|
||||
auto iterations1 (0);
|
||||
while (system.nodes [0]->ledger.account_balance (rai::transaction (system.nodes [0]->store.environment, nullptr, false), rai::test_genesis_key.pub) == amount1)
|
||||
{
|
||||
system.poll ();
|
||||
++iterations1;
|
||||
ASSERT_LT (iterations1, 200);
|
||||
}
|
||||
auto iterations2 (0);
|
||||
auto again (true);
|
||||
while (again)
|
||||
{
|
||||
wallet->send_action (rai::test_genesis_key.pub, key.pub, 100);
|
||||
auto iterations1 (0);
|
||||
while (system.nodes [0]->ledger.account_balance (rai::transaction (system.nodes [0]->store.environment, nullptr, false), rai::test_genesis_key.pub) == amount1)
|
||||
{
|
||||
system.poll ();
|
||||
++iterations2;
|
||||
ASSERT_LT (iterations2, 200);
|
||||
++iterations1;
|
||||
ASSERT_LT (iterations1, 200);
|
||||
}
|
||||
auto iterations2 (0);
|
||||
auto again (true);
|
||||
while (again)
|
||||
{
|
||||
system.poll ();
|
||||
++iterations2;
|
||||
ASSERT_LT (iterations2, 200);
|
||||
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
|
||||
again = wallet->store.work_get (transaction, account1, work1) || system.work.work_validate (system.nodes [0]->ledger.latest_root (transaction, account1), work1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST (wallet, unsynced_work)
|
||||
|
|
|
@ -423,7 +423,7 @@ void rai::frontier_req_client::next (MDB_txn * transaction_a)
|
|||
auto iterator (connection->node->store.latest_begin (transaction_a, rai::uint256_union (current.number () + 1)));
|
||||
if (iterator != connection->node->store.latest_end ())
|
||||
{
|
||||
current = rai::account (iterator->first);
|
||||
current = rai::account (iterator->first.uint256 ());
|
||||
info = rai::account_info (iterator->second);
|
||||
}
|
||||
else
|
||||
|
@ -665,7 +665,7 @@ void rai::bulk_push_client::push (MDB_txn * transaction_a)
|
|||
auto first (connection->node->store.unsynced_begin (transaction_a));
|
||||
if (first != rai::store_iterator (nullptr))
|
||||
{
|
||||
rai::block_hash hash (first->first);
|
||||
rai::block_hash hash (first->first.uint256 ());
|
||||
if (!hash.is_zero ())
|
||||
{
|
||||
connection->node->store.unsynced_del (transaction_a, hash);
|
||||
|
@ -1696,7 +1696,7 @@ void rai::frontier_req_server::next ()
|
|||
auto iterator (connection->node->store.latest_begin (transaction, current.number () + 1));
|
||||
if (iterator != connection->node->store.latest_end ())
|
||||
{
|
||||
current = rai::uint256_union (iterator->first);
|
||||
current = rai::uint256_union (iterator->first.uint256 ());
|
||||
info = rai::account_info (iterator->second);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -3189,7 +3189,7 @@ bool rai::handle_node_options (boost::program_options::variables_map & vm)
|
|||
std::cout << boost::str (boost::format ("Seed: %1%\n") % seed.data.to_string ());
|
||||
for (auto i (existing->second->store.begin (transaction)), m (existing->second->store.end ()); i != m; ++i)
|
||||
{
|
||||
rai::account account (i->first);
|
||||
rai::account account (i->first.uint256 ());
|
||||
rai::raw_key key;
|
||||
auto error (existing->second->store.fetch (transaction, account, key));
|
||||
assert (!error);
|
||||
|
@ -3324,7 +3324,7 @@ bool rai::handle_node_options (boost::program_options::variables_map & vm)
|
|||
rai::transaction transaction (i->second->store.environment, nullptr, false);
|
||||
for (auto j (i->second->store.begin (transaction)), m (i->second->store.end ()); j != m; ++j)
|
||||
{
|
||||
std::cout << rai::uint256_union (j->first).to_account () << '\n';
|
||||
std::cout << rai::uint256_union (j->first.uint256 ()).to_account () << '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -369,7 +369,7 @@ void rai::rpc_handler::account_list ()
|
|||
for (auto i (existing->second->store.begin (transaction)), j (existing->second->store.end ()); i != j; ++i)
|
||||
{
|
||||
boost::property_tree::ptree entry;
|
||||
entry.put ("", rai::uint256_union (i->first).to_account ());
|
||||
entry.put ("", rai::uint256_union (i->first.uint256 ()).to_account ());
|
||||
accounts.push_back (std::make_pair ("", entry));
|
||||
}
|
||||
response_l.add_child ("accounts", accounts);
|
||||
|
@ -1407,7 +1407,7 @@ void rai::rpc_handler::delegators ()
|
|||
if (block->representative() == account) {
|
||||
std::string balance;
|
||||
rai::uint128_union (info.balance).encode_dec (balance);
|
||||
delegators.put (rai::account (i->first).to_account (), balance);
|
||||
delegators.put (rai::account (i->first.uint256 ()).to_account (), balance);
|
||||
}
|
||||
}
|
||||
response_l.add_child ("delegators", delegators);
|
||||
|
@ -1499,7 +1499,7 @@ void rai::rpc_handler::frontiers ()
|
|||
rai::transaction transaction (node.store.environment, nullptr, false);
|
||||
for (auto i (node.store.latest_begin (transaction, start)), n (node.store.latest_end ()); i != n && frontiers.size () < count; ++i)
|
||||
{
|
||||
frontiers.put (rai::account (i->first).to_account (), rai::account_info (i->second).head.to_string ());
|
||||
frontiers.put (rai::account (i->first.uint256 ()).to_account (), rai::account_info (i->second).head.to_string ());
|
||||
}
|
||||
response_l.add_child ("frontiers", frontiers);
|
||||
response (response_l);
|
||||
|
@ -1776,7 +1776,7 @@ void rai::rpc_handler::ledger ()
|
|||
for (auto i (node.store.latest_begin (transaction, start)), n (node.store.latest_end ()); i != n && accounts.size () < count; ++i)
|
||||
{
|
||||
rai::account_info info (i->second);
|
||||
rai::account account (i->first);
|
||||
rai::account account (i->first.uint256 ());
|
||||
boost::property_tree::ptree response_l;
|
||||
response_l.put ("frontier", info.head.to_string ());
|
||||
response_l.put ("open_block", info.open_block.to_string ());
|
||||
|
@ -1811,7 +1811,7 @@ void rai::rpc_handler::ledger ()
|
|||
for (auto i (node.store.latest_begin (transaction, start)), n (node.store.latest_end ()); i != n; ++i)
|
||||
{
|
||||
rai::uint128_union balance (rai::account_info (i->second).balance);
|
||||
ledger_l.push_back (std::make_pair (balance, rai::account (i->first)));
|
||||
ledger_l.push_back (std::make_pair (balance, rai::account (i->first.uint256 ())));
|
||||
}
|
||||
std::sort (ledger_l.begin (), ledger_l.end ());
|
||||
std::reverse (ledger_l.begin (), ledger_l.end ());
|
||||
|
@ -2665,7 +2665,7 @@ void rai::rpc_handler::representatives ()
|
|||
{
|
||||
for (auto i (node.store.representation_begin (transaction)), n (node.store.representation_end ()); i != n && representatives.size () < count; ++i)
|
||||
{
|
||||
rai::account account(i->first);
|
||||
rai::account account(i->first.uint256 ());
|
||||
auto amount (node.store.representation_get (transaction, account));
|
||||
representatives.put (account.to_account (), amount.convert_to <std::string> ());
|
||||
}
|
||||
|
@ -2675,7 +2675,7 @@ void rai::rpc_handler::representatives ()
|
|||
std::vector <std::pair <rai::uint128_union, std::string>> representation;
|
||||
for (auto i (node.store.representation_begin (transaction)), n (node.store.representation_end ()); i != n; ++i)
|
||||
{
|
||||
rai::account account(i->first);
|
||||
rai::account account(i->first.uint256 ());
|
||||
auto amount (node.store.representation_get (transaction, account));
|
||||
representation.push_back (std::make_pair (amount, account.to_account ()));
|
||||
}
|
||||
|
@ -3099,7 +3099,7 @@ void rai::rpc_handler::unchecked_keys ()
|
|||
auto block (rai::deserialize_block (stream));
|
||||
std::string contents;
|
||||
block->serialize_json (contents);
|
||||
entry.put ("key", rai::block_hash (i->first).to_string ());
|
||||
entry.put ("key", rai::block_hash (i->first.uint256 ()).to_string ());
|
||||
entry.put ("hash", block->hash ().to_string ());
|
||||
entry.put ("contents", contents);
|
||||
unchecked.push_back (std::make_pair ("", entry));
|
||||
|
@ -3198,7 +3198,7 @@ void rai::rpc_handler::wallet_balance_total ()
|
|||
rai::transaction transaction (node.store.environment, nullptr, false);
|
||||
for (auto i (existing->second->store.begin (transaction)), n (existing->second->store.end ()); i != n; ++i)
|
||||
{
|
||||
rai::account account(i->first);
|
||||
rai::account account(i->first.uint256 ());
|
||||
balance = balance + node.ledger.account_balance (transaction, account);
|
||||
pending = pending + node.ledger.account_pending (transaction, account);
|
||||
}
|
||||
|
@ -3243,7 +3243,7 @@ void rai::rpc_handler::wallet_balances ()
|
|||
rai::transaction transaction (node.store.environment, nullptr, false);
|
||||
for (auto i (existing->second->store.begin (transaction)), n (existing->second->store.end ()); i != n; ++i)
|
||||
{
|
||||
rai::account account(i->first);
|
||||
rai::account account(i->first.uint256 ());
|
||||
rai::uint128_t balance = node.ledger.account_balance (transaction, account);
|
||||
if (threshold.is_zero ())
|
||||
{
|
||||
|
@ -3458,7 +3458,7 @@ void rai::rpc_handler::wallet_frontiers ()
|
|||
rai::transaction transaction (node.store.environment, nullptr, false);
|
||||
for (auto i (existing->second->store.begin (transaction)), n (existing->second->store.end ()); i != n; ++i)
|
||||
{
|
||||
rai::account account(i->first);
|
||||
rai::account account (i->first.uint256 ());
|
||||
auto latest (node.ledger.latest (transaction, account));
|
||||
if (!latest.is_zero ())
|
||||
{
|
||||
|
@ -3582,7 +3582,7 @@ void rai::rpc_handler::wallet_pending ()
|
|||
rai::transaction transaction (node.store.environment, nullptr, false);
|
||||
for (auto i (existing->second->store.begin (transaction)), n (existing->second->store.end ()); i != n; ++i)
|
||||
{
|
||||
rai::account account(i->first);
|
||||
rai::account account (i->first.uint256 ());
|
||||
boost::property_tree::ptree peers_l;
|
||||
rai::account end (account.number () + 1);
|
||||
for (auto ii (node.store.pending_begin (transaction, rai::pending_key (account, 0))), nn (node.store.pending_begin (transaction, rai::pending_key (end, 0))); ii != nn && peers_l.size ()< count; ++ii)
|
||||
|
@ -3724,7 +3724,7 @@ void rai::rpc_handler::wallet_republish ()
|
|||
rai::transaction transaction (node.store.environment, nullptr, false);
|
||||
for (auto i (existing->second->store.begin (transaction)), n (existing->second->store.end ()); i != n; ++i)
|
||||
{
|
||||
rai::account account(i->first);
|
||||
rai::account account (i->first.uint256 ());
|
||||
auto latest (node.ledger.latest (transaction, account));
|
||||
std::unique_ptr <rai::block> block;
|
||||
std::vector <rai::block_hash> hashes;
|
||||
|
@ -3785,7 +3785,7 @@ void rai::rpc_handler::wallet_work_get ()
|
|||
rai::transaction transaction (node.store.environment, nullptr, false);
|
||||
for (auto i (existing->second->store.begin (transaction)), n (existing->second->store.end ()); i != n; ++i)
|
||||
{
|
||||
rai::account account(i->first);
|
||||
rai::account account (i->first.uint256 ());
|
||||
uint64_t work (0);
|
||||
auto error_work (existing->second->store.work_get (transaction, account, work));
|
||||
works.put (account.to_account (), rai::to_string_hex (work));
|
||||
|
|
|
@ -66,7 +66,7 @@ rai::account rai::system::account (MDB_txn * transaction_a, size_t index_a)
|
|||
assert (keys != wallet_l->store.end ());
|
||||
auto result (keys->first);
|
||||
assert (++keys == wallet_l->store.end ());
|
||||
return result;
|
||||
return result.uint256 ();
|
||||
}
|
||||
|
||||
void rai::system::poll ()
|
||||
|
@ -245,7 +245,7 @@ void rai::system::generate_send_existing (rai::node & node_a, std::vector <rai::
|
|||
entry = node_a.store.latest_begin (transaction);
|
||||
}
|
||||
assert (entry != node_a.store.latest_end ());
|
||||
destination = rai::account (entry->first);
|
||||
destination = rai::account (entry->first.uint256 ());
|
||||
source = get_random_account (accounts_a);
|
||||
amount = get_random_amount (transaction, node_a, source);
|
||||
}
|
||||
|
|
|
@ -285,7 +285,7 @@ void rai::wallet_store::deterministic_clear (MDB_txn * transaction_a)
|
|||
{
|
||||
case rai::key_type::deterministic:
|
||||
{
|
||||
rai::uint256_union key (i->first);
|
||||
rai::uint256_union key (i->first.uint256 ());
|
||||
erase (transaction_a, key);
|
||||
i = begin (transaction_a, key);
|
||||
break;
|
||||
|
@ -538,7 +538,7 @@ std::vector <rai::account> rai::wallet_store::accounts (MDB_txn * transaction_a)
|
|||
std::vector <rai::account> result;
|
||||
for (auto i (begin (transaction_a)), n (end ()); i != n; ++i)
|
||||
{
|
||||
rai::account account (i->first);
|
||||
rai::account account (i->first.uint256 ());
|
||||
result.push_back (account);
|
||||
}
|
||||
return result;
|
||||
|
@ -688,19 +688,19 @@ bool rai::wallet_store::fetch (MDB_txn * transaction_a, rai::public_key const &
|
|||
|
||||
bool rai::wallet_store::exists (MDB_txn * transaction_a, rai::public_key const & pub)
|
||||
{
|
||||
return find (transaction_a, pub) != end ();
|
||||
return find (transaction_a, pub) != end ();
|
||||
}
|
||||
|
||||
void rai::wallet_store::serialize_json (MDB_txn * transaction_a, std::string & string_a)
|
||||
{
|
||||
boost::property_tree::ptree tree;
|
||||
for (rai::store_iterator i (transaction_a, handle), n (nullptr); i != n; ++i)
|
||||
{
|
||||
tree.put (rai::uint256_union (i->first).to_string (), rai::wallet_value (i->second).key.to_string ());
|
||||
}
|
||||
std::stringstream ostream;
|
||||
boost::property_tree::write_json (ostream, tree);
|
||||
string_a = ostream.str ();
|
||||
boost::property_tree::ptree tree;
|
||||
for (rai::store_iterator i (transaction_a, handle), n (nullptr); i != n; ++i)
|
||||
{
|
||||
tree.put (rai::uint256_union (i->first.uint256 ()).to_string (), rai::wallet_value (i->second).key.to_string ());
|
||||
}
|
||||
std::stringstream ostream;
|
||||
boost::property_tree::write_json (ostream, tree);
|
||||
string_a = ostream.str ();
|
||||
}
|
||||
|
||||
void rai::wallet_store::write_backup (MDB_txn * transaction_a, boost::filesystem::path const & path_a)
|
||||
|
@ -717,40 +717,40 @@ void rai::wallet_store::write_backup (MDB_txn * transaction_a, boost::filesystem
|
|||
|
||||
bool rai::wallet_store::move (MDB_txn * transaction_a, rai::wallet_store & other_a, std::vector <rai::public_key> const & keys)
|
||||
{
|
||||
assert (valid_password (transaction_a));
|
||||
assert (other_a.valid_password (transaction_a));
|
||||
auto result (false);
|
||||
for (auto i (keys.begin ()), n (keys.end ()); i != n; ++i)
|
||||
{
|
||||
rai::raw_key prv;
|
||||
auto error (other_a.fetch (transaction_a, *i, prv));
|
||||
result = result | error;
|
||||
if (!result)
|
||||
{
|
||||
insert_adhoc (transaction_a, prv);
|
||||
other_a.erase (transaction_a, *i);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
assert (valid_password (transaction_a));
|
||||
assert (other_a.valid_password (transaction_a));
|
||||
auto result (false);
|
||||
for (auto i (keys.begin ()), n (keys.end ()); i != n; ++i)
|
||||
{
|
||||
rai::raw_key prv;
|
||||
auto error (other_a.fetch (transaction_a, *i, prv));
|
||||
result = result | error;
|
||||
if (!result)
|
||||
{
|
||||
insert_adhoc (transaction_a, prv);
|
||||
other_a.erase (transaction_a, *i);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool rai::wallet_store::import (MDB_txn * transaction_a, rai::wallet_store & other_a)
|
||||
{
|
||||
assert (valid_password (transaction_a));
|
||||
assert (other_a.valid_password (transaction_a));
|
||||
auto result (false);
|
||||
for (auto i (other_a.begin (transaction_a)), n (end ()); i != n; ++i)
|
||||
{
|
||||
rai::raw_key prv;
|
||||
auto error (other_a.fetch (transaction_a, i->first, prv));
|
||||
result = result | error;
|
||||
if (!result)
|
||||
{
|
||||
insert_adhoc (transaction_a, prv);
|
||||
other_a.erase (transaction_a, i->first);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
assert (valid_password (transaction_a));
|
||||
assert (other_a.valid_password (transaction_a));
|
||||
auto result (false);
|
||||
for (auto i (other_a.begin (transaction_a)), n (end ()); i != n; ++i)
|
||||
{
|
||||
rai::raw_key prv;
|
||||
auto error (other_a.fetch (transaction_a, i->first.uint256 (), prv));
|
||||
result = result | error;
|
||||
if (!result)
|
||||
{
|
||||
insert_adhoc (transaction_a, prv);
|
||||
other_a.erase (transaction_a, i->first.uint256 ());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool rai::wallet_store::work_get (MDB_txn * transaction_a, rai::public_key const & pub_a, uint64_t & work_a)
|
||||
|
@ -796,15 +796,15 @@ void rai::wallet_store::upgrade_v1_v2 ()
|
|||
assert (version (transaction) == 1);
|
||||
rai::raw_key zero_password;
|
||||
rai::wallet_value value (entry_get_raw (transaction, rai::wallet_store::wallet_key_special));
|
||||
rai::raw_key kdf;
|
||||
rai::raw_key kdf;
|
||||
kdf.data.clear ();
|
||||
zero_password.decrypt (value.key, kdf, salt (transaction).owords [0]);
|
||||
zero_password.decrypt (value.key, kdf, salt (transaction).owords [0]);
|
||||
derive_key (kdf, transaction, "");
|
||||
rai::raw_key empty_password;
|
||||
empty_password.decrypt (value.key, kdf, salt (transaction).owords [0]);
|
||||
for (auto i (begin (transaction)), n (end ()); i != n; ++i)
|
||||
{
|
||||
rai::public_key key (i->first);
|
||||
rai::public_key key (i->first.uint256 ());
|
||||
rai::raw_key prv;
|
||||
if (fetch (transaction, key, prv))
|
||||
{
|
||||
|
@ -1269,7 +1269,7 @@ public:
|
|||
{
|
||||
for (auto i (wallet_a->store.begin (transaction_a)), n (wallet_a->store.end ()); i != n; ++i)
|
||||
{
|
||||
keys.insert (i->first);
|
||||
keys.insert (i->first.uint256 ());
|
||||
}
|
||||
}
|
||||
void run ()
|
||||
|
@ -1382,7 +1382,7 @@ void rai::wallet::init_free_accounts (MDB_txn * transaction_a)
|
|||
free_accounts.clear ();
|
||||
for (auto i (store.begin (transaction_a)), n (store.end ()); i != n; ++i)
|
||||
{
|
||||
free_accounts.insert (i->first);
|
||||
free_accounts.insert (i->first.uint256 ());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1543,28 +1543,28 @@ void rai::wallets::queue_wallet_action (rai::account const & account_a, rai::uin
|
|||
|
||||
void rai::wallets::foreach_representative (MDB_txn * transaction_a, std::function <void (rai::public_key const & pub_a, rai::raw_key const & prv_a)> const & action_a)
|
||||
{
|
||||
for (auto i (items.begin ()), n (items.end ()); i != n; ++i)
|
||||
{
|
||||
auto & wallet (*i->second);
|
||||
for (auto i (items.begin ()), n (items.end ()); i != n; ++i)
|
||||
{
|
||||
auto & wallet (*i->second);
|
||||
for (auto j (wallet.store.begin (transaction_a)), m (wallet.store.end ()); j != m; ++j)
|
||||
{
|
||||
rai::account account (j->first);
|
||||
{
|
||||
rai::account account (j->first.uint256 ());
|
||||
if (!node.ledger.weight (transaction_a, account).is_zero ())
|
||||
{
|
||||
if (wallet.store.valid_password (transaction_a))
|
||||
{
|
||||
rai::raw_key prv;
|
||||
auto error (wallet.store.fetch (transaction_a, j->first, prv));
|
||||
auto error (wallet.store.fetch (transaction_a, j->first.uint256 (), prv));
|
||||
assert (!error);
|
||||
action_a (j->first, prv);
|
||||
action_a (j->first.uint256 (), prv);
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LOG (node.log) << boost::str (boost::format ("Skipping locked wallet %1% with account %2%") % i->first.to_string () % account.to_account ());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool rai::wallets::exists (MDB_txn * transaction_a, rai::public_key const & account_a)
|
||||
|
@ -1582,39 +1582,39 @@ rai::uint128_t const rai::wallets::high_priority = std::numeric_limits <rai::uin
|
|||
|
||||
rai::store_iterator rai::wallet_store::begin (MDB_txn * transaction_a)
|
||||
{
|
||||
rai::store_iterator result (transaction_a, handle, rai::mdb_val (rai::uint256_union (special_count)));
|
||||
return result;
|
||||
rai::store_iterator result (transaction_a, handle, rai::mdb_val (rai::uint256_union (special_count)));
|
||||
return result;
|
||||
}
|
||||
|
||||
rai::store_iterator rai::wallet_store::begin (MDB_txn * transaction_a, rai::uint256_union const & key)
|
||||
{
|
||||
rai::store_iterator result (transaction_a, handle, rai::mdb_val (key));
|
||||
rai::store_iterator result (transaction_a, handle, rai::mdb_val (key));
|
||||
return result;
|
||||
}
|
||||
|
||||
rai::store_iterator rai::wallet_store::find (MDB_txn * transaction_a, rai::uint256_union const & key)
|
||||
{
|
||||
auto result (begin (transaction_a, key));
|
||||
rai::store_iterator end (nullptr);
|
||||
if (result != end)
|
||||
{
|
||||
if (rai::uint256_union (result->first) == key)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return end;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return end;
|
||||
}
|
||||
rai::store_iterator end (nullptr);
|
||||
if (result != end)
|
||||
{
|
||||
if (rai::uint256_union (result->first.uint256 ()) == key)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return end;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return end;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
rai::store_iterator rai::wallet_store::end ()
|
||||
{
|
||||
return rai::store_iterator (nullptr);
|
||||
return rai::store_iterator (nullptr);
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ void rai_qt::accounts::refresh_wallet_balance ()
|
|||
rai::uint128_t pending (0);
|
||||
for (auto i (this->wallet.wallet_m->store.begin (transaction)), j (this->wallet.wallet_m->store.end ()); i != j; ++i)
|
||||
{
|
||||
rai::public_key key (i->first);
|
||||
rai::public_key key (i->first.uint256 ());
|
||||
balance = balance + (this->wallet.node.ledger.account_balance (transaction, key));
|
||||
pending = pending + (this->wallet.node.ledger.account_pending (transaction, key));
|
||||
}
|
||||
|
@ -268,12 +268,12 @@ void rai_qt::accounts::refresh_wallet_balance ()
|
|||
|
||||
void rai_qt::accounts::refresh ()
|
||||
{
|
||||
model->removeRows (0, model->rowCount ());
|
||||
model->removeRows (0, model->rowCount ());
|
||||
rai::transaction transaction (wallet.wallet_m->store.environment, nullptr, false);
|
||||
QBrush brush;
|
||||
for (auto i (wallet.wallet_m->store.begin (transaction)), j (wallet.wallet_m->store.end ()); i != j; ++i)
|
||||
{
|
||||
rai::public_key key (i->first);
|
||||
for (auto i (wallet.wallet_m->store.begin (transaction)), j (wallet.wallet_m->store.end ()); i != j; ++i)
|
||||
{
|
||||
rai::public_key key (i->first.uint256 ());
|
||||
auto balance_amount (wallet.node.ledger.account_balance (transaction, key));
|
||||
bool display (true);
|
||||
switch (wallet.wallet_m->store.key_type (i->second))
|
||||
|
@ -301,7 +301,7 @@ void rai_qt::accounts::refresh ()
|
|||
items.push_back (account);
|
||||
model->appendRow (items);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rai_qt::import::import (rai_qt::wallet & wallet_a) :
|
||||
|
@ -1717,21 +1717,21 @@ void rai_qt::advanced_actions::refresh_peers ()
|
|||
|
||||
void rai_qt::advanced_actions::refresh_ledger ()
|
||||
{
|
||||
ledger_model->removeRows (0, ledger_model->rowCount ());
|
||||
ledger_model->removeRows (0, ledger_model->rowCount ());
|
||||
rai::transaction transaction (wallet.node.store.environment, nullptr, false);
|
||||
for (auto i (wallet.node.ledger.store.latest_begin (transaction)), j (wallet.node.ledger.store.latest_end ()); i != j; ++i)
|
||||
{
|
||||
QList <QStandardItem *> items;
|
||||
items.push_back (new QStandardItem (QString (rai::block_hash (i->first).to_account ().c_str ())));
|
||||
for (auto i (wallet.node.ledger.store.latest_begin (transaction)), j (wallet.node.ledger.store.latest_end ()); i != j; ++i)
|
||||
{
|
||||
QList <QStandardItem *> items;
|
||||
items.push_back (new QStandardItem (QString (rai::block_hash (i->first.uint256 ()).to_account ().c_str ())));
|
||||
rai::account_info info (i->second);
|
||||
std::string balance;
|
||||
rai::amount (info.balance.number () / wallet.rendering_ratio).encode_dec (balance);
|
||||
items.push_back (new QStandardItem (QString (balance.c_str ())));
|
||||
std::string block_hash;
|
||||
info.head.encode_hex (block_hash);
|
||||
items.push_back (new QStandardItem (QString (block_hash.c_str ())));
|
||||
ledger_model->appendRow (items);
|
||||
}
|
||||
items.push_back (new QStandardItem (QString (balance.c_str ())));
|
||||
std::string block_hash;
|
||||
info.head.encode_hex (block_hash);
|
||||
items.push_back (new QStandardItem (QString (block_hash.c_str ())));
|
||||
ledger_model->appendRow (items);
|
||||
}
|
||||
}
|
||||
|
||||
rai_qt::block_entry::block_entry (rai_qt::wallet & wallet_a) :
|
||||
|
|
|
@ -145,8 +145,8 @@ int main (int argc, char * const * argv)
|
|||
{
|
||||
data_path = rai::working_path ();
|
||||
}
|
||||
rai_daemon::daemon daemon;
|
||||
daemon.run (data_path);
|
||||
rai_daemon::daemon daemon;
|
||||
daemon.run (data_path);
|
||||
}
|
||||
else if (vm.count ("debug_block_count"))
|
||||
{
|
||||
|
@ -209,7 +209,7 @@ int main (int argc, char * const * argv)
|
|||
rai::uint128_t total;
|
||||
for (auto i(node.node->store.representation_begin(transaction)), n(node.node->store.representation_end()); i != n; ++i)
|
||||
{
|
||||
rai::account account(i->first);
|
||||
rai::account account (i->first.uint256 ());
|
||||
auto amount (node.node->store.representation_get(transaction, account));
|
||||
total += amount;
|
||||
std::cout << boost::str(boost::format("%1% %2% %3%\n") % account.to_account () % amount.convert_to <std::string> () % total.convert_to<std::string> ());
|
||||
|
@ -217,7 +217,7 @@ int main (int argc, char * const * argv)
|
|||
std::map <rai::account, rai::uint128_t> calculated;
|
||||
for (auto i (node.node->store.latest_begin (transaction)), n (node.node->store.latest_end ()); i != n; ++i)
|
||||
{
|
||||
rai::account account (i->first);
|
||||
rai::account account (i->first.uint256 ());
|
||||
rai::account_info info (i->second);
|
||||
rai::block_hash rep_block (node.node->ledger.representative_calculated (transaction, info.head));
|
||||
std::unique_ptr <rai::block> block (node.node->store.block_get (transaction, rep_block));
|
||||
|
@ -236,41 +236,41 @@ int main (int argc, char * const * argv)
|
|||
rai::transaction transaction (node.node->store.environment, nullptr, false);
|
||||
std::cout << boost::str (boost::format ("Frontier count: %1%\n") % node.node->store.frontier_count (transaction));
|
||||
}
|
||||
else if (vm.count ("debug_mass_activity"))
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
size_t count (1000000);
|
||||
system.generate_mass_activity (count, *system.nodes [0]);
|
||||
}
|
||||
else if (vm.count ("debug_profile_kdf"))
|
||||
{
|
||||
else if (vm.count ("debug_mass_activity"))
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
size_t count (1000000);
|
||||
system.generate_mass_activity (count, *system.nodes [0]);
|
||||
}
|
||||
else if (vm.count ("debug_profile_kdf"))
|
||||
{
|
||||
rai::uint256_union result;
|
||||
rai::uint256_union salt (0);
|
||||
std::string password ("");
|
||||
for (; true;)
|
||||
{
|
||||
auto begin1 (std::chrono::high_resolution_clock::now ());
|
||||
for (; true;)
|
||||
{
|
||||
auto begin1 (std::chrono::high_resolution_clock::now ());
|
||||
auto success (argon2_hash (1, rai::wallet_store::kdf_work, 1, password.data (), password.size (), salt.bytes.data (), salt.bytes.size (), result.bytes.data (), result.bytes.size (), NULL, 0, Argon2_d, 0x10));
|
||||
auto end1 (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << boost::str (boost::format ("Derivation time: %1%us\n") % std::chrono::duration_cast <std::chrono::microseconds> (end1 - begin1).count ());
|
||||
}
|
||||
}
|
||||
else if (vm.count ("debug_profile_generate"))
|
||||
{
|
||||
std::cerr << boost::str (boost::format ("Derivation time: %1%us\n") % std::chrono::duration_cast <std::chrono::microseconds> (end1 - begin1).count ());
|
||||
}
|
||||
}
|
||||
else if (vm.count ("debug_profile_generate"))
|
||||
{
|
||||
rai::work_pool work (std::numeric_limits <unsigned>::max (), nullptr);
|
||||
rai::change_block block (0, 0, rai::keypair ().prv, 0, 0);
|
||||
std::cerr << "Starting generation profiling\n";
|
||||
for (uint64_t i (0); true; ++i)
|
||||
{
|
||||
block.hashables.previous.qwords [0] += 1;
|
||||
auto begin1 (std::chrono::high_resolution_clock::now ());
|
||||
block.block_work_set (work.generate (block.root ()));
|
||||
auto end1 (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << boost::str (boost::format ("%|1$ 12d|\n") % std::chrono::duration_cast <std::chrono::microseconds> (end1 - begin1).count ());
|
||||
}
|
||||
}
|
||||
else if (vm.count ("debug_opencl"))
|
||||
{
|
||||
rai::change_block block (0, 0, rai::keypair ().prv, 0, 0);
|
||||
std::cerr << "Starting generation profiling\n";
|
||||
for (uint64_t i (0); true; ++i)
|
||||
{
|
||||
block.hashables.previous.qwords [0] += 1;
|
||||
auto begin1 (std::chrono::high_resolution_clock::now ());
|
||||
block.block_work_set (work.generate (block.root ()));
|
||||
auto end1 (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << boost::str (boost::format ("%|1$ 12d|\n") % std::chrono::duration_cast <std::chrono::microseconds> (end1 - begin1).count ());
|
||||
}
|
||||
}
|
||||
else if (vm.count ("debug_opencl"))
|
||||
{
|
||||
bool error (false);
|
||||
rai::opencl_environment environment (error);
|
||||
if (!error)
|
||||
|
@ -348,42 +348,42 @@ int main (int argc, char * const * argv)
|
|||
std::cout << "Error initializing OpenCL" << std::endl;
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
else if (vm.count ("debug_profile_verify"))
|
||||
{
|
||||
}
|
||||
else if (vm.count ("debug_profile_verify"))
|
||||
{
|
||||
rai::work_pool work (std::numeric_limits <unsigned>::max (), nullptr);
|
||||
rai::change_block block (0, 0, rai::keypair ().prv, 0, 0);
|
||||
std::cerr << "Starting verification profiling\n";
|
||||
for (uint64_t i (0); true; ++i)
|
||||
{
|
||||
block.hashables.previous.qwords [0] += 1;
|
||||
auto begin1 (std::chrono::high_resolution_clock::now ());
|
||||
for (uint64_t t (0); t < 1000000; ++t)
|
||||
{
|
||||
block.hashables.previous.qwords [0] += 1;
|
||||
block.block_work_set (t);
|
||||
work.work_validate (block);
|
||||
}
|
||||
auto end1 (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << boost::str (boost::format ("%|1$ 12d|\n") % std::chrono::duration_cast <std::chrono::microseconds> (end1 - begin1).count ());
|
||||
}
|
||||
}
|
||||
else if (vm.count ("debug_verify_profile"))
|
||||
{
|
||||
rai::keypair key;
|
||||
rai::uint256_union message;
|
||||
rai::uint512_union signature;
|
||||
signature = rai::sign_message (key.prv, key.pub, message);
|
||||
auto begin (std::chrono::high_resolution_clock::now ());
|
||||
for (auto i (0u); i < 1000; ++i)
|
||||
{
|
||||
rai::validate_message (key.pub, message, signature);
|
||||
}
|
||||
auto end (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << "Signature verifications " << std::chrono::duration_cast <std::chrono::microseconds> (end - begin).count () << std::endl;
|
||||
}
|
||||
else if (vm.count ("debug_profile_sign"))
|
||||
{
|
||||
rai::change_block block (0, 0, rai::keypair ().prv, 0, 0);
|
||||
std::cerr << "Starting verification profiling\n";
|
||||
for (uint64_t i (0); true; ++i)
|
||||
{
|
||||
block.hashables.previous.qwords [0] += 1;
|
||||
auto begin1 (std::chrono::high_resolution_clock::now ());
|
||||
for (uint64_t t (0); t < 1000000; ++t)
|
||||
{
|
||||
block.hashables.previous.qwords [0] += 1;
|
||||
block.block_work_set (t);
|
||||
work.work_validate (block);
|
||||
}
|
||||
auto end1 (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << boost::str (boost::format ("%|1$ 12d|\n") % std::chrono::duration_cast <std::chrono::microseconds> (end1 - begin1).count ());
|
||||
}
|
||||
}
|
||||
else if (vm.count ("debug_verify_profile"))
|
||||
{
|
||||
rai::keypair key;
|
||||
rai::uint256_union message;
|
||||
rai::uint512_union signature;
|
||||
signature = rai::sign_message (key.prv, key.pub, message);
|
||||
auto begin (std::chrono::high_resolution_clock::now ());
|
||||
for (auto i (0u); i < 1000; ++i)
|
||||
{
|
||||
rai::validate_message (key.pub, message, signature);
|
||||
}
|
||||
auto end (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << "Signature verifications " << std::chrono::duration_cast <std::chrono::microseconds> (end - begin).count () << std::endl;
|
||||
}
|
||||
else if (vm.count ("debug_profile_sign"))
|
||||
{
|
||||
std::cerr << "Starting blocks signing profiling\n";
|
||||
for (uint64_t i (0); true; ++i)
|
||||
{
|
||||
|
@ -397,69 +397,69 @@ int main (int argc, char * const * argv)
|
|||
}
|
||||
auto end1 (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << boost::str (boost::format ("%|1$ 12d|\n") % std::chrono::duration_cast <std::chrono::microseconds> (end1 - begin1).count ());
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
else if (vm.count ("debug_xorshift_profile"))
|
||||
{
|
||||
auto unaligned (new uint8_t [64 * 1024 * 1024 + 16]);
|
||||
auto aligned (reinterpret_cast <void *> (reinterpret_cast <uintptr_t> (unaligned) & ~uintptr_t (0xfu)));
|
||||
{
|
||||
memset (aligned, 0x0, 64 * 1024 * 1024);
|
||||
auto begin (std::chrono::high_resolution_clock::now ());
|
||||
for (auto i (0u); i < 1000; ++i)
|
||||
{
|
||||
fill_zero (aligned);
|
||||
}
|
||||
auto end (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << "Memset " << std::chrono::duration_cast <std::chrono::microseconds> (end - begin).count () << std::endl;
|
||||
}
|
||||
{
|
||||
memset (aligned, 0x0, 64 * 1024 * 1024);
|
||||
auto begin (std::chrono::high_resolution_clock::now ());
|
||||
for (auto i (0u); i < 1000; ++i)
|
||||
{
|
||||
fill_128_reference (aligned);
|
||||
}
|
||||
auto end (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << "Ref fill 128 " << std::chrono::duration_cast <std::chrono::microseconds> (end - begin).count () << std::endl;
|
||||
}
|
||||
{
|
||||
memset (aligned, 0x0, 64 * 1024 * 1024);
|
||||
auto begin (std::chrono::high_resolution_clock::now ());
|
||||
for (auto i (0u); i < 1000; ++i)
|
||||
{
|
||||
fill_1024_reference (aligned);
|
||||
}
|
||||
auto end (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << "Ref fill 1024 " << std::chrono::duration_cast <std::chrono::microseconds> (end - begin).count () << std::endl;
|
||||
}
|
||||
{
|
||||
memset (aligned, 0x0, 64 * 1024 * 1024);
|
||||
auto begin (std::chrono::high_resolution_clock::now ());
|
||||
for (auto i (0u); i < 1000; ++i)
|
||||
{
|
||||
fill_128_sse (aligned);
|
||||
}
|
||||
auto end (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << "SSE fill 128 " << std::chrono::duration_cast <std::chrono::microseconds> (end - begin).count () << std::endl;
|
||||
}
|
||||
{
|
||||
memset (aligned, 0x0, 64 * 1024 * 1024);
|
||||
auto begin (std::chrono::high_resolution_clock::now ());
|
||||
for (auto i (0u); i < 1000; ++i)
|
||||
{
|
||||
fill_1024_sse (aligned);
|
||||
}
|
||||
auto end (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << "SSE fill 1024 " << std::chrono::duration_cast <std::chrono::microseconds> (end - begin).count () << std::endl;
|
||||
}
|
||||
}
|
||||
#endif // 0
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
else if (vm.count ("debug_xorshift_profile"))
|
||||
{
|
||||
auto unaligned (new uint8_t [64 * 1024 * 1024 + 16]);
|
||||
auto aligned (reinterpret_cast <void *> (reinterpret_cast <uintptr_t> (unaligned) & ~uintptr_t (0xfu)));
|
||||
{
|
||||
memset (aligned, 0x0, 64 * 1024 * 1024);
|
||||
auto begin (std::chrono::high_resolution_clock::now ());
|
||||
for (auto i (0u); i < 1000; ++i)
|
||||
{
|
||||
fill_zero (aligned);
|
||||
}
|
||||
auto end (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << "Memset " << std::chrono::duration_cast <std::chrono::microseconds> (end - begin).count () << std::endl;
|
||||
}
|
||||
{
|
||||
memset (aligned, 0x0, 64 * 1024 * 1024);
|
||||
auto begin (std::chrono::high_resolution_clock::now ());
|
||||
for (auto i (0u); i < 1000; ++i)
|
||||
{
|
||||
fill_128_reference (aligned);
|
||||
}
|
||||
auto end (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << "Ref fill 128 " << std::chrono::duration_cast <std::chrono::microseconds> (end - begin).count () << std::endl;
|
||||
}
|
||||
{
|
||||
memset (aligned, 0x0, 64 * 1024 * 1024);
|
||||
auto begin (std::chrono::high_resolution_clock::now ());
|
||||
for (auto i (0u); i < 1000; ++i)
|
||||
{
|
||||
fill_1024_reference (aligned);
|
||||
}
|
||||
auto end (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << "Ref fill 1024 " << std::chrono::duration_cast <std::chrono::microseconds> (end - begin).count () << std::endl;
|
||||
}
|
||||
{
|
||||
memset (aligned, 0x0, 64 * 1024 * 1024);
|
||||
auto begin (std::chrono::high_resolution_clock::now ());
|
||||
for (auto i (0u); i < 1000; ++i)
|
||||
{
|
||||
fill_128_sse (aligned);
|
||||
}
|
||||
auto end (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << "SSE fill 128 " << std::chrono::duration_cast <std::chrono::microseconds> (end - begin).count () << std::endl;
|
||||
}
|
||||
{
|
||||
memset (aligned, 0x0, 64 * 1024 * 1024);
|
||||
auto begin (std::chrono::high_resolution_clock::now ());
|
||||
for (auto i (0u); i < 1000; ++i)
|
||||
{
|
||||
fill_1024_sse (aligned);
|
||||
}
|
||||
auto end (std::chrono::high_resolution_clock::now ());
|
||||
std::cerr << "SSE fill 1024 " << std::chrono::duration_cast <std::chrono::microseconds> (end - begin).count () << std::endl;
|
||||
}
|
||||
}
|
||||
#endif // 0
|
||||
else
|
||||
{
|
||||
std::cout << description << std::endl;
|
||||
result = -1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ int run_wallet (QApplication & application, int argc, char * const * argv, boost
|
|||
auto existing (wallet->store.begin (transaction));
|
||||
if (existing != wallet->store.end ())
|
||||
{
|
||||
rai::uint256_union account (existing->first);
|
||||
rai::uint256_union account (existing->first.uint256 ());
|
||||
config.account = account;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1570,7 +1570,7 @@ int rai::block_store::version_get (MDB_txn * transaction_a)
|
|||
}
|
||||
else
|
||||
{
|
||||
rai::uint256_union version_value (data);
|
||||
rai::uint256_union version_value (data.uint256 ());
|
||||
assert (version_value.qwords [2] == 0 && version_value.qwords [1] == 0 && version_value.qwords [0] == 0);
|
||||
result = version_value.number ().convert_to <int> ();
|
||||
}
|
||||
|
@ -1616,7 +1616,7 @@ void rai::block_store::upgrade_v1_to_v2 (MDB_txn * transaction_a)
|
|||
std::cerr << std::hex;
|
||||
if (i != rai::store_iterator (nullptr))
|
||||
{
|
||||
account = i->first;
|
||||
account = i->first.uint256 ();
|
||||
rai::account_info_v1 v1 (i->second);
|
||||
rai::account_info_v5 v2;
|
||||
v2.balance = v1.balance;
|
||||
|
@ -1688,7 +1688,7 @@ void rai::block_store::upgrade_v2_to_v3 (MDB_txn * transaction_a)
|
|||
mdb_drop (transaction_a, representation, 0);
|
||||
for (auto i (latest_begin (transaction_a)), n (latest_end ()); i != n; ++i)
|
||||
{
|
||||
rai::account account_l (i->first);
|
||||
rai::account account_l (i->first.uint256 ());
|
||||
rai::account_info_v5 info (i->second);
|
||||
representative_visitor visitor (transaction_a, *this);
|
||||
visitor.compute (info.head);
|
||||
|
@ -1705,7 +1705,7 @@ void rai::block_store::upgrade_v3_to_v4 (MDB_txn * transaction_a)
|
|||
std::queue <std::pair <rai::pending_key, rai::pending_info>> items;
|
||||
for (auto i (pending_begin (transaction_a)), n (pending_end ()); i != n; ++i)
|
||||
{
|
||||
rai::block_hash hash (i->first);
|
||||
rai::block_hash hash (i->first.uint256 ());
|
||||
rai::pending_info_v3 info (i->second);
|
||||
items.push (std::make_pair (rai::pending_key (info.destination, hash), rai::pending_info (info.source, info.amount)));
|
||||
}
|
||||
|
@ -1723,7 +1723,7 @@ void rai::block_store::upgrade_v4_to_v5 (MDB_txn * transaction_a)
|
|||
version_put (transaction_a, 5);
|
||||
for (auto i (latest_begin (transaction_a)), n (latest_end ()); i != n; ++i)
|
||||
{
|
||||
rai::account account (i->first);
|
||||
rai::account account (i->first.uint256 ());
|
||||
rai::account_info_v5 info (i->second);
|
||||
rai::block_hash successor (0);
|
||||
auto block (block_get (transaction_a, info.head));
|
||||
|
@ -1749,7 +1749,7 @@ void rai::block_store::upgrade_v5_to_v6 (MDB_txn * transaction_a)
|
|||
std::deque <std::pair <rai::account, rai::account_info>> headers;
|
||||
for (auto i (latest_begin (transaction_a)), n (latest_end ()); i != n; ++i)
|
||||
{
|
||||
rai::account account (i->first);
|
||||
rai::account account (i->first.uint256 ());
|
||||
rai::account_info_v5 info_old (i->second);
|
||||
uint64_t block_count (0);
|
||||
auto hash (info_old.head);
|
||||
|
@ -1796,7 +1796,7 @@ void rai::block_store::upgrade_v8_to_v9 (MDB_txn * transaction_a)
|
|||
uint64_t sequence;
|
||||
auto error (rai::read (stream, sequence));
|
||||
// Create a dummy vote with the same sequence number for easy upgrading. This won't have a valid signature.
|
||||
auto dummy (std::make_shared <rai::vote> (rai::account (i->first), junk.prv, sequence, block));
|
||||
auto dummy (std::make_shared <rai::vote> (rai::account (i->first.uint256 ()), junk.prv, sequence, block));
|
||||
std::vector <uint8_t> vector;
|
||||
{
|
||||
rai::vectorstream stream (vector);
|
||||
|
@ -1818,7 +1818,7 @@ void rai::block_store::upgrade_v9_to_v10 (MDB_txn * transaction_a)
|
|||
rai::account_info info (i->second);
|
||||
if (info.block_count >= block_info_max)
|
||||
{
|
||||
rai::account account (i->first);
|
||||
rai::account account (i->first.uint256 ());
|
||||
std::cerr << boost::str (boost::format ("Upgrading account %1%...\n") % account.to_account ());
|
||||
size_t block_count (1);
|
||||
auto hash (info.open_block);
|
||||
|
@ -1983,7 +1983,7 @@ std::unique_ptr <rai::block> rai::block_store::block_random (MDB_txn * transacti
|
|||
existing = rai::store_iterator (transaction_a, database);
|
||||
}
|
||||
assert (existing != rai::store_iterator (nullptr));
|
||||
return block_get (transaction_a, rai::block_hash (existing->first));
|
||||
return block_get (transaction_a, rai::block_hash (existing->first.uint256 ()));
|
||||
}
|
||||
|
||||
std::unique_ptr <rai::block> rai::block_store::block_random (MDB_txn * transaction_a)
|
||||
|
@ -2138,7 +2138,7 @@ void rai::block_store::account_del (MDB_txn * transaction_a, rai::account const
|
|||
bool rai::block_store::account_exists (MDB_txn * transaction_a, rai::account const & account_a)
|
||||
{
|
||||
auto iterator (latest_begin (transaction_a, account_a));
|
||||
return iterator != rai::store_iterator (nullptr) && rai::account (iterator->first) == account_a;
|
||||
return iterator != rai::store_iterator (nullptr) && rai::account (iterator->first.uint256 ()) == account_a;
|
||||
}
|
||||
|
||||
bool rai::block_store::account_get (MDB_txn * transaction_a, rai::account const & account_a, rai::account_info & info_a)
|
||||
|
@ -2174,7 +2174,7 @@ rai::account rai::block_store::frontier_get (MDB_txn * transaction_a, rai::block
|
|||
rai::account result (0);
|
||||
if (status == 0)
|
||||
{
|
||||
result = value;
|
||||
result = value.uint256 ();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -2358,7 +2358,7 @@ void rai::block_store::block_info_del (MDB_txn * transaction_a, rai::block_hash
|
|||
bool rai::block_store::block_info_exists (MDB_txn * transaction_a, rai::block_hash const & hash_a)
|
||||
{
|
||||
auto iterator (block_info_begin (transaction_a, hash_a));
|
||||
return iterator != rai::store_iterator (nullptr) && rai::block_hash (iterator->first) == hash_a;
|
||||
return iterator != rai::store_iterator (nullptr) && rai::block_hash (iterator->first.uint256 ()) == hash_a;
|
||||
}
|
||||
|
||||
bool rai::block_store::block_info_get (MDB_txn * transaction_a, rai::block_hash const & hash_a, rai::block_info & block_info_a)
|
||||
|
@ -2509,7 +2509,7 @@ std::vector <std::shared_ptr <rai::block>> rai::block_store::unchecked_get (MDB_
|
|||
result.push_back (i->second);
|
||||
}
|
||||
}
|
||||
for (auto i (unchecked_begin (transaction_a, hash_a)), n (unchecked_end ()); i != n && rai::block_hash (i->first) == hash_a; i.next_dup ())
|
||||
for (auto i (unchecked_begin (transaction_a, hash_a)), n (unchecked_end ()); i != n && rai::block_hash (i->first.uint256 ()) == hash_a; i.next_dup ())
|
||||
{
|
||||
rai::bufferstream stream (reinterpret_cast <uint8_t const *> (i->second.data ()), i->second.size());
|
||||
result.push_back (rai::deserialize_block (stream));
|
||||
|
@ -2584,7 +2584,7 @@ void rai::block_store::unsynced_del (MDB_txn * transaction_a, rai::block_hash co
|
|||
bool rai::block_store::unsynced_exists (MDB_txn * transaction_a, rai::block_hash const & hash_a)
|
||||
{
|
||||
auto iterator (unsynced_begin (transaction_a, hash_a));
|
||||
return iterator != rai::store_iterator (nullptr) && rai::block_hash (iterator->first) == hash_a;
|
||||
return iterator != rai::store_iterator (nullptr) && rai::block_hash (iterator->first.uint256 ()) == hash_a;
|
||||
}
|
||||
|
||||
rai::store_iterator rai::block_store::unsynced_begin (MDB_txn * transaction_a)
|
||||
|
|
|
@ -130,6 +130,14 @@ size_t rai::mdb_val::size () const
|
|||
return value.mv_size;
|
||||
}
|
||||
|
||||
rai::uint256_union rai::mdb_val::uint256 () const
|
||||
{
|
||||
rai::uint256_union result;
|
||||
assert (size () == sizeof (result));
|
||||
std::copy (reinterpret_cast <uint8_t const *> (data ()), reinterpret_cast <uint8_t const *> (data ()) + sizeof (result), result.bytes.data ());
|
||||
return result;
|
||||
}
|
||||
|
||||
rai::mdb_val::operator MDB_val * () const
|
||||
{
|
||||
// Allow passing a temporary to a non-c++ function which doesn't have constness
|
||||
|
@ -313,13 +321,6 @@ void rai::uint256_union::encrypt (rai::raw_key const & cleartext, rai::raw_key c
|
|||
enc.ProcessData (bytes.data (), cleartext.data.bytes.data (), sizeof (cleartext.data.bytes));
|
||||
}
|
||||
|
||||
rai::uint256_union::uint256_union (rai::mdb_val const & val_a)
|
||||
{
|
||||
assert (val_a.size () == sizeof (*this));
|
||||
static_assert (sizeof (bytes) == sizeof (*this), "Class not packed");
|
||||
std::copy (reinterpret_cast <uint8_t const *> (val_a.data ()), reinterpret_cast <uint8_t const *> (val_a.data ()) + sizeof (*this), bytes.data ());
|
||||
}
|
||||
|
||||
bool rai::uint256_union::is_zero () const
|
||||
{
|
||||
return qwords [0] == 0 && qwords [1] == 0 && qwords [2] == 0 && qwords [3] == 0;
|
||||
|
|
|
@ -186,7 +186,6 @@ union uint256_union
|
|||
uint256_union (std::string const &);
|
||||
uint256_union (uint64_t);
|
||||
uint256_union (rai::uint256_t const &);
|
||||
uint256_union (rai::mdb_val const &);
|
||||
void encrypt (rai::raw_key const &, rai::raw_key const &, uint128_union const &);
|
||||
uint256_union & operator ^= (rai::uint256_union const &);
|
||||
uint256_union operator ^ (rai::uint256_union const &) const;
|
||||
|
@ -262,6 +261,7 @@ public:
|
|||
mdb_val (rai::uint256_union const &);
|
||||
void * data () const;
|
||||
size_t size () const;
|
||||
rai::uint256_union uint256 () const;
|
||||
operator MDB_val * () const;
|
||||
operator MDB_val const & () const;
|
||||
MDB_val value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue