Skip to content

Commit

Permalink
Update QT GUI account history
Browse files Browse the repository at this point in the history
  • Loading branch information
SergiySW authored Oct 27, 2024
1 parent 88659b5 commit 1cc71dd
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions nano/qt/qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ class short_text_visitor : public nano::block_visitor
if (!amount_l)
{
type = "Send (pruned)";
amount = 0;
}
else
{
Expand All @@ -542,32 +543,41 @@ class short_text_visitor : public nano::block_visitor
type = "Receive";
auto account_l = ledger.any.block_account (transaction, block_a.hashables.source);
auto amount_l = ledger.any.block_amount (transaction, block_a.hash ());
if (!account_l || !amount_l)
if (!account_l)
{
type = "Receive (pruned)";
type = "Receive (pruned source)";
}
else
{
account = account_l.value ();
}
if (!amount_l)
{
type = "Receive (pruned)";
amount = 0;
}
else
{
amount = amount_l.value ().number ();
}
}
void open_block (nano::open_block const & block_a)
{
type = "Receive";
if (block_a.hashables.source != ledger.constants.genesis->account ().as_union ())
if (block_a.hashables.source != ledger.constants.genesis->account ())
{
auto account_l = ledger.any.block_account (transaction, block_a.hashables.source);
auto amount_l = ledger.any.block_amount (transaction, block_a.hash ());
if (!account_l || !amount_l)
if (!account_l)
{
type = "Receive (pruned)";
type = "Receive (pruned source)";
}
else
{
account = account_l.value ();
amount = amount_l.value ().number ();
}
debug_assert (amount_l);
amount = amount_l.value ().number ();
}
else
{
Expand All @@ -586,7 +596,7 @@ class short_text_visitor : public nano::block_visitor
auto balance (block_a.hashables.balance.number ());
auto previous_balance = ledger.any.block_balance (transaction, block_a.hashables.previous);
// Error to receive previous block balance means that previous block was pruned from the ledger
if ((!previous_balance && block_a.sideband ().details.is_send) || balance < previous_balance.value ().number ())
if ((!previous_balance || balance < previous_balance.value ().number ()) && block_a.sideband ().details.is_send)
{
type = "Send";
account = block_a.hashables.link.as_account ();
Expand All @@ -600,9 +610,9 @@ class short_text_visitor : public nano::block_visitor
amount = previous_balance.value ().number () - balance;
}
}
else if (block_a.hashables.link.is_zero ())
else if (block_a.hashables.link.is_zero () && !block_a.sideband ().details.is_send)
{
debug_assert (!block_a.sideband ().details.is_send && !block_a.sideband ().details.is_receive && !block_a.sideband ().details.is_epoch);
debug_assert (!block_a.sideband ().details.is_receive && !block_a.sideband ().details.is_epoch);
type = "Change";
account = block_a.hashables.representative;
amount = 0;
Expand Down Expand Up @@ -634,7 +644,7 @@ class short_text_visitor : public nano::block_visitor
auto account_l = ledger.any.block_account (transaction, block_a.hashables.link.as_block_hash ());
if (!account_l)
{
type = "Receive (pruned sender)";
type = "Receive (pruned source)";
}
else
{
Expand All @@ -646,8 +656,12 @@ class short_text_visitor : public nano::block_visitor
{
// Receive block with previous balance error is pruned only if it isn't open block for an account
type = "Receive (pruned)";
amount = 0;
}
else
{
amount = balance;
}
amount = 0;
}
else
{
Expand Down

0 comments on commit 1cc71dd

Please sign in to comment.