Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor changes #1840

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8> = row.get(0);
Expand Down
2 changes: 1 addition & 1 deletion chainstate/src/detail/median_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ mod test {
initial_prev: Id<GenBlock>,
initial_time: BlockTimestampInternalType,
) -> Vec<Block> {
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 {
Expand Down
17 changes: 7 additions & 10 deletions chainstate/src/detail/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,16 +260,13 @@ impl<S: BlockchainStorage, V: TransactionVerificationStrategy> Chainstate<S, V>
}

fn broadcast_new_tip_event(&mut self, new_block_index: &Option<BlockIndex>) {
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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions chainstate/test-framework/src/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl TestFramework {
) -> Result<Vec<Id<GenBlock>>, ChainstateError> {
let mut prev_block_id = *parent_block;
let result = || -> Result<Vec<Id<GenBlock>>, 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()
Expand Down Expand Up @@ -251,7 +251,7 @@ impl TestFramework {
) -> Result<Vec<Id<GenBlock>>, ChainstateError> {
let mut prev_block_id = *parent_block;
let result = || -> Result<Vec<Id<GenBlock>>, 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());
Expand Down
5 changes: 2 additions & 3 deletions common/src/chain/transaction/signature/sighash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ use self::hashable::{SignatureHashableElement, SignatureHashableInputs};
use super::{DestinationSigError, Signable};

fn hash_encoded_if_some<T: Encode>(val: &Option<T>, stream: &mut DefaultHashAlgoStream) {
match val {
Some(ref v) => hash_encoded_to(&v, stream),
None => (),
if let Some(v) = val {
hash_encoded_to(&v, stream)
}
}

Expand Down
7 changes: 3 additions & 4 deletions dns-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion test-rpc-functions/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)];
Expand Down
Loading