Skip to content

Commit

Permalink
Update pruned blocks detection in QT GUI history
Browse files Browse the repository at this point in the history
  • Loading branch information
SergiySW authored Oct 25, 2024
1 parent e735273 commit fe35fd6
Showing 1 changed file with 49 additions and 24 deletions.
73 changes: 49 additions & 24 deletions nano/qt/qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,44 +585,69 @@ 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);
if (!block_a.hashables.previous.is_zero () && !previous_balance)
// 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 ())
{
type = "Unknown (pruned)";
type = "Send";
account = block_a.hashables.link.as_account ();
if (!previous_balance)
{
type = "Send (pruned)";
amount = 0;
}
else
{
amount = previous_balance.value ().number () - balance;
}
}
else if (block_a.hashables.link.is_zero ())
{
debug_assert (!block_a.sideband ().details.is_send && !block_a.sideband ().details.is_receive && !block_a.sideband ().details.is_epoch);
type = "Change";
account = block_a.hashables.representative;
amount = 0;
account = block_a.hashables.account;
if (!previous_balance)
{
type = "Change (pruned)";
}
else
{
debug_assert (balance == previous_balance);
}
}
else if (balance < previous_balance.value ().number ())
else if (ledger.is_epoch_link (block_a.hashables.link) && block_a.sideband ().details.is_epoch)
{
type = "Send";
amount = previous_balance.value ().number () - balance;
account = block_a.hashables.link.as_account ();
debug_assert (!previous_balance || balance == previous_balance);
type = "Epoch";
amount = 0;
if (!previous_balance)
{
type = "Epoch (pruned)";
}
account = ledger.epoch_signer (block_a.hashables.link);
}
else
{
if (block_a.hashables.link.is_zero ())
debug_assert (block_a.sideband ().details.is_receive);
type = "Receive";
auto account_l = ledger.any.block_account (transaction, block_a.hashables.link.as_block_hash ());
if (!account_l)
{
type = "Receive (pruned sender)";
}
else
{
type = "Change";
account = block_a.hashables.representative;
account = account_l.value ();
}
else if (balance == previous_balance && ledger.is_epoch_link (block_a.hashables.link))
if (!previous_balance)
{
type = "Epoch";
account = ledger.epoch_signer (block_a.hashables.link);
type = "Receive (pruned)";
amount = 0;
}
else
{
type = "Receive";
auto account_l = ledger.any.block_account (transaction, block_a.hashables.link.as_block_hash ());
if (!account_l)
{
type = "Receive (pruned)";
}
else
{
account = account_l.value ();
}
amount = balance - previous_balance.value ().number ();
}
amount = balance - previous_balance.value ().number ();
}
}
nano::secure::transaction const & transaction;
Expand Down

0 comments on commit fe35fd6

Please sign in to comment.