Skip to content

Commit

Permalink
Explain the odd transaction_status_sender.is_some()
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun committed Dec 18, 2024
1 parent 3b852f6 commit a59e39a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions unified-scheduler-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,17 @@ impl TaskHandler for DefaultTaskHandler {
BlockVerification => vec![index],
BlockProduction => {
let mut vec = vec![];
// transaction_status_sender is usually None for staked nodes because it's only
// used for RPC-related additional data recording. However, a staked node could
// also be running with rpc functionalities during development. So, we need to
// correctly support the use case for produced blocks as well, like verified blocks
// via the replaying stage.
// Refer `record_token_balances` in `execute_batch()` as this conditional treatment
// is mirrored from it.
if handler_context.transaction_status_sender.is_some() {
// Create empty vec with the exact needed capacity, which will be filled inside
// `execute_batch()` below. Otherwise, excess cap would be reserved on
// `.push(transaction_index)` in it.
// Adjust the empty new vec with the exact needed capacity, which will be
// filled inside `execute_batch()` below. Otherwise, excess cap would be
// reserved on `.push(transaction_index)` in it.
vec.reserve_exact(1);
}
vec
Expand Down

0 comments on commit a59e39a

Please sign in to comment.