Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the sideband when available in ledger.is_send #2620

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions nano/lib/blocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ void nano::block::sideband_set (nano::block_sideband const & sideband_a)
sideband_m = sideband_a;
}

bool nano::block::has_sideband () const
{
return sideband_m.is_initialized ();
}

nano::account const & nano::block::representative () const
{
static nano::account rep{ 0 };
Expand Down
1 change: 1 addition & 0 deletions nano/lib/blocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class block
nano::block_hash full_hash () const;
nano::block_sideband const & sideband () const;
void sideband_set (nano::block_sideband const &);
bool has_sideband () const;
std::string to_json () const;
virtual void hash (blake2b_state &) const = 0;
virtual uint64_t block_work () const = 0;
Expand Down
15 changes: 11 additions & 4 deletions nano/secure/ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,12 +807,19 @@ std::string nano::ledger::block_text (nano::block_hash const & hash_a)
bool nano::ledger::is_send (nano::transaction const & transaction_a, nano::state_block const & block_a) const
{
bool result (false);
nano::block_hash previous (block_a.hashables.previous);
if (!previous.is_zero ())
if (block_a.has_sideband ())
{
if (block_a.hashables.balance < balance (transaction_a, previous))
result = block_a.sideband ().details.is_send;
}
else
{
nano::block_hash previous (block_a.hashables.previous);
if (!previous.is_zero ())
{
result = true;
if (block_a.hashables.balance < balance (transaction_a, previous))
{
result = true;
}
}
}
return result;
Expand Down