Skip to content

Commit

Permalink
clippy: manual_inspect (#2496)
Browse files Browse the repository at this point in the history
fix manual_inspect
  • Loading branch information
yihau authored Aug 9, 2024
1 parent 2cc0b4a commit 4ac1300
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 18 deletions.
3 changes: 1 addition & 2 deletions install/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ fn download_to_temp(

impl<R: Read> Read for DownloadProgress<R> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.response.read(buf).map(|n| {
self.response.read(buf).inspect(|&n| {
self.progress_bar.inc(n as u64);
n
})
}
}
Expand Down
3 changes: 1 addition & 2 deletions ledger/src/ancestor_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<'a> Iterator for AncestorIterator<'a> {

fn next(&mut self) -> Option<Self::Item> {
let current = self.current;
current.map(|slot| {
current.inspect(|&slot| {
if slot != 0 {
self.current = self
.blockstore
Expand All @@ -45,7 +45,6 @@ impl<'a> Iterator for AncestorIterator<'a> {
} else {
self.current = None;
}
slot
})
}
}
Expand Down
3 changes: 1 addition & 2 deletions poh/src/poh_recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,11 +992,10 @@ impl PohRecorder {
self.send_entry_us += send_entry_us;
send_entry_res?;
let starting_transaction_index =
working_bank.transaction_index.map(|transaction_index| {
working_bank.transaction_index.inspect(|transaction_index| {
let next_starting_transaction_index =
transaction_index.saturating_add(num_transactions);
working_bank.transaction_index = Some(next_starting_transaction_index);
transaction_index
});
return Ok(starting_transaction_index);
}
Expand Down
3 changes: 1 addition & 2 deletions remote-wallet/src/bin/ledger-udev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ fn main() -> Result<(), Box<dyn error::Error>> {
.append(true)
.create(true)
.open(LEDGER_UDEV_RULES_LOCATION)
.map_err(|e| {
.inspect_err(|_e| {
println!("Could not write to file; this script requires sudo privileges");
e
})?;
file.write_all(LEDGER_UDEV_RULES.as_bytes())?;

Expand Down
3 changes: 1 addition & 2 deletions svm/src/transaction_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,8 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
let compute_budget_limits = process_compute_budget_instructions(
message.program_instructions_iter(),
)
.map_err(|err| {
.inspect_err(|_err| {
error_counters.invalid_compute_budget += 1;
err
})?;

let fee_payer_address = message.fee_payer();
Expand Down
3 changes: 1 addition & 2 deletions test-validator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,14 +629,13 @@ impl TestValidatorGenesis {
socket_addr_space,
rpc_to_plugin_manager_receiver,
)
.map(|test_validator| {
.inspect(|test_validator| {
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_io()
.enable_time()
.build()
.unwrap();
runtime.block_on(test_validator.wait_for_nonzero_fees());
test_validator
})
}

Expand Down
10 changes: 4 additions & 6 deletions turbine/src/retransmit_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,8 @@ fn retransmit(
quic_endpoint_sender,
stats,
)
.map_err(|err| {
stats.record_error(&err);
err
.inspect_err(|err| {
stats.record_error(err);
})
.ok()?;
Some((key.slot(), root_distance, num_nodes))
Expand All @@ -290,9 +289,8 @@ fn retransmit(
quic_endpoint_sender,
stats,
)
.map_err(|err| {
stats.record_error(&err);
err
.inspect_err(|err| {
stats.record_error(err);
})
.ok()?;
Some((key.slot(), root_distance, num_nodes))
Expand Down

0 comments on commit 4ac1300

Please sign in to comment.