Skip to content

Commit

Permalink
Pulling block information from unconfirmed set.
Browse files Browse the repository at this point in the history
  • Loading branch information
clemahieu committed Mar 10, 2024
1 parent e05a826 commit bef31c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions nano/core_test/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ TEST (wallet, send_async)
system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv);
nano::keypair key2;
std::thread thread ([&system] () {
ASSERT_TIMELY (10s, system.nodes[0]->balance (nano::dev::genesis_key.pub).is_zero ());
ASSERT_TIMELY (10s, system.nodes[0]->ledger.unconfirmed_balance (system.nodes[0]->store.tx_begin_read (), nano::dev::genesis_key.pub).is_zero ());
});
std::atomic<bool> success (false);
system.wallet (0)->send_async (nano::dev::genesis_key.pub, key2.pub, std::numeric_limits<nano::uint128_t>::max (), [&success] (std::shared_ptr<nano::block> const & block_a) { ASSERT_NE (nullptr, block_a); success = true; });
Expand Down Expand Up @@ -681,9 +681,11 @@ TEST (wallet, work_cache_delayed)
}
nano::keypair key;
auto block1 (wallet->send_action (nano::dev::genesis_key.pub, key.pub, 100));
ASSERT_TIMELY_EQ (5s, block1->hash (), node1.latest (nano::dev::genesis_key.pub));
ASSERT_NE (nullptr, block1);
ASSERT_TIMELY_EQ (5s, block1->hash (), node1.ledger.unconfirmed_latest (node1.store.tx_begin_read (), nano::dev::genesis_key.pub));
auto block2 (wallet->send_action (nano::dev::genesis_key.pub, key.pub, 100));
ASSERT_TIMELY_EQ (5s, block2->hash (), node1.latest (nano::dev::genesis_key.pub));
ASSERT_NE (nullptr, block2);
ASSERT_TIMELY_EQ (5s, block2->hash (), node1.ledger.unconfirmed_latest (node1.store.tx_begin_read (), nano::dev::genesis_key.pub));
ASSERT_TIMELY_EQ (5s, block2->hash (), node1.wallets.delayed_work->operator[] (nano::dev::genesis_key.pub).as_block_hash ());
auto threshold (node1.default_difficulty (nano::work_version::work_1));
auto again (true);
Expand Down
4 changes: 2 additions & 2 deletions nano/node/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,10 +976,10 @@ std::shared_ptr<nano::block> nano::wallet::send_action (nano::account const & so
if (existing != store.end ())
{
// TODO These need to reference unchecked values
auto balance (wallets.node.ledger.account_balance (block_transaction, source_a));
auto balance (wallets.node.ledger.unconfirmed_balance (block_transaction, source_a));
if (!balance.is_zero () && balance >= amount_a)
{
auto info = wallets.node.ledger.account_info (block_transaction, source_a);
auto info = wallets.node.ledger.unconfirmed_account_info (block_transaction, source_a);
debug_assert (info);
nano::raw_key prv;
auto error2 (store.fetch (transaction, source_a, prv));
Expand Down

0 comments on commit bef31c1

Please sign in to comment.