Skip to content

Commit

Permalink
fix(core): dont request full non-tip block if block is empty (#4802)
Browse files Browse the repository at this point in the history
Description
---
- checks for edge-case which prevents an unnecessary full candidate block request when block is empty.

Motivation and Context
---
A full block request for empty block is not necessary as we already have all the information required to construct the candidate block. This check was missing from the branch where the candidate block is not the next tip block.

How Has This Been Tested?
---
  • Loading branch information
sdbondi authored Oct 19, 2022
1 parent 2bea05f commit becff0f
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,13 @@ where B: BlockchainBackend + 'static
current_meta.best_block().to_hex(),
source_peer,
);
if excess_sigs.is_empty() {
let block = BlockBuilder::new(header.version)
.with_coinbase_utxo(coinbase_output, coinbase_kernel)
.with_header(header.clone())
.build();
return Ok(block);
}
metrics::compact_block_tx_misses(header.height).set(excess_sigs.len() as i64);
let block = self.request_full_block_from_peer(source_peer, block_hash).await?;
return Ok(block);
Expand Down

0 comments on commit becff0f

Please sign in to comment.