Skip to content

Commit

Permalink
Refactor handle_receive_block.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Jun 29, 2024
1 parent b58be1d commit 8626467
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions src/protocols/protocol_block_in_31800.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,34 +302,24 @@ bool protocol_block_in_31800::handle_receive_block(const code& ec,
const auto checked = is_under_checkpoint(height) ||
query.is_milestone(link);

// Transaction commitments and malleation are checked under bypass.
// Invalidity is only stored in the case where a strong header has been
// stored, later to be found out as invalid. The invalidity prevents repeat
// processing of the same invalid chain but is not logically necessary. It
// is not stored in the case where the block is malleated32/64.
// Tx commitments and malleation are checked under bypass. Invalidity is
// only stored when a strong header has been stored, later to be found out
// as invalid and not malleable. Stored invalidity prevents repeat
// processing of the same invalid chain but is not logically necessary.
if (const auto code = check(*block_ptr, it->context, checked))
{
// These imply that we don't have actual block represented by the hash.
if (code == system::error::invalid_transaction_commitment ||
code == system::error::invalid_witness_commitment)
code == system::error::invalid_witness_commitment ||
code == system::error::block_malleated)
{
LOGR("Uncommitted block [" << encode_hash(hash) << ":" << height
<< "] from [" << authority() << "] " << code.message());
stop(code);
return false;
}

if (code == system::error::block_malleated)
{
LOGR("Malleated block [" << encode_hash(hash) << ":" << height
<< "] from [" << authority() << "] " << code.message());

// event sent to re-obtain the correct block.
notify(error::success, chase::malleated, link);
stop(code);
return false;
}

// Mark unconfirmable non-malleated block.
// Actual block represented by the hash is unconfirmable.
if (!query.set_block_unconfirmable(link))
{
LOGF("Failure setting block unconfirmable [" << encode_hash(hash)
Expand Down

0 comments on commit 8626467

Please sign in to comment.