diff --git a/Cargo.toml b/Cargo.toml index 57864b184a..3587ea839f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -124,7 +124,7 @@ utxo = { path = "utxo" } [workspace.package] edition = "2021" -rust-version = "1.80" +rust-version = "1.82" version = "0.7.0" license = "MIT" diff --git a/api-server/api-server-common/src/storage/impls/postgres/queries.rs b/api-server/api-server-common/src/storage/impls/postgres/queries.rs index 38c21cf729..d66be8102d 100644 --- a/api-server/api-server-common/src/storage/impls/postgres/queries.rs +++ b/api-server/api-server-common/src/storage/impls/postgres/queries.rs @@ -306,7 +306,7 @@ impl<'a, 'b> QueryFromConnection<'a, 'b> { .await .map_err(|e| ApiServerStorageError::LowLevelStorageError(e.to_string()))?; - let mut transaction_ids = vec![]; + let mut transaction_ids = Vec::with_capacity(rows.len()); for row in &rows { let transaction_id: Vec = row.get(0); diff --git a/chainstate/src/detail/median_time.rs b/chainstate/src/detail/median_time.rs index 8b1989746a..7b28898ceb 100644 --- a/chainstate/src/detail/median_time.rs +++ b/chainstate/src/detail/median_time.rs @@ -82,7 +82,7 @@ mod test { initial_prev: Id, initial_time: BlockTimestampInternalType, ) -> Vec { - let mut res = vec![]; + let mut res = Vec::with_capacity(count); let mut prev = initial_prev; let mut time = initial_time; for _ in 0..count { diff --git a/chainstate/src/detail/mod.rs b/chainstate/src/detail/mod.rs index 5180f36271..e33fa39e22 100644 --- a/chainstate/src/detail/mod.rs +++ b/chainstate/src/detail/mod.rs @@ -260,16 +260,13 @@ impl Chainstate } fn broadcast_new_tip_event(&mut self, new_block_index: &Option) { - match new_block_index { - Some(ref new_block_index) => { - let new_height = new_block_index.block_height(); - let new_id = *new_block_index.block_id(); - let event = ChainstateEvent::NewTip(new_id, new_height); - - self.rpc_events.broadcast(&event); - self.subsystem_events.broadcast(event); - } - None => (), + if let Some(new_block_index) = new_block_index { + let new_height = new_block_index.block_height(); + let new_id = *new_block_index.block_id(); + let event = ChainstateEvent::NewTip(new_id, new_height); + + self.rpc_events.broadcast(&event); + self.subsystem_events.broadcast(event); } } diff --git a/chainstate/test-framework/src/framework.rs b/chainstate/test-framework/src/framework.rs index f603a77f67..e31ffcd228 100644 --- a/chainstate/test-framework/src/framework.rs +++ b/chainstate/test-framework/src/framework.rs @@ -220,7 +220,7 @@ impl TestFramework { ) -> Result>, ChainstateError> { let mut prev_block_id = *parent_block; let result = || -> Result>, ChainstateError> { - let mut ids = Vec::new(); + let mut ids = Vec::with_capacity(blocks_count); for _ in 0..blocks_count { let block = self .make_block_builder() @@ -251,7 +251,7 @@ impl TestFramework { ) -> Result>, ChainstateError> { let mut prev_block_id = *parent_block; let result = || -> Result>, ChainstateError> { - let mut ids = Vec::new(); + let mut ids = Vec::with_capacity(blocks_count); let target_block_time = self.chain_config().target_block_spacing(); for _ in 0..blocks_count { self.progress_time_seconds_since_epoch(target_block_time.as_secs()); diff --git a/common/src/chain/transaction/signature/sighash/mod.rs b/common/src/chain/transaction/signature/sighash/mod.rs index 9424f2365a..c8e932edc4 100644 --- a/common/src/chain/transaction/signature/sighash/mod.rs +++ b/common/src/chain/transaction/signature/sighash/mod.rs @@ -32,9 +32,8 @@ use self::hashable::{SignatureHashableElement, SignatureHashableInputs}; use super::{DestinationSigError, Signable}; fn hash_encoded_if_some(val: &Option, stream: &mut DefaultHashAlgoStream) { - match val { - Some(ref v) => hash_encoded_to(&v, stream), - None => (), + if let Some(v) = val { + hash_encoded_to(&v, stream) } } diff --git a/dns-server/src/main.rs b/dns-server/src/main.rs index db10dcb03a..9abbcd78c0 100644 --- a/dns-server/src/main.rs +++ b/dns-server/src/main.rs @@ -191,8 +191,7 @@ async fn main() { let run_options = DnsServerRunOptions::parse(); let result = run(run_options).await; - if let Err(err) = result { - eprintln!("DnsServer failed: {err:?}"); - std::process::exit(1) - } + let Err(err) = result; + eprintln!("DnsServer failed: {err:?}"); + std::process::exit(1) } diff --git a/test-rpc-functions/src/rpc.rs b/test-rpc-functions/src/rpc.rs index fcfa88fd8f..d5aa9ad89b 100644 --- a/test-rpc-functions/src/rpc.rs +++ b/test-rpc-functions/src/rpc.rs @@ -342,7 +342,7 @@ impl RpcTestFunctionsRpcServer for super::RpcTestFunctionsHandle { let coin_decimal_factor = 10u128.pow(coin_decimals as u32); let mut amount_to_spend = (amount_to_spend as u128) * coin_decimal_factor; let fee_per_tx = (fee_per_tx as u128) * coin_decimal_factor; - let mut transactions = vec![]; + let mut transactions = Vec::with_capacity(num_transactions as usize); for _ in 0..num_transactions { let inputs = vec![TxInput::from_utxo(OutPointSourceId::Transaction(input_tx_id), input_idx)];