Skip to content

Commit 769c94d

Browse files
committed
Merge branch 'develop' of https://github.com/stacks-network/stacks-core into chore/clippy-unnecesary-to-owned-unwrap-or-default
2 parents f95abc5 + a46254d commit 769c94d

File tree

138 files changed

+1576
-1657
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+1576
-1657
lines changed

contrib/tools/relay-server/src/url.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ impl QueryEx for str {
99
match self.split_once('?') {
1010
Some((_, right)) if !right.is_empty() => right
1111
.split('&')
12-
.map(|v| v.split_once('=').unwrap_or((v, &"")))
12+
.map(|v| v.split_once('=').unwrap_or((v, "")))
1313
.collect(),
1414
_ => HashMap::new(),
1515
}

stacks-common/src/types/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ impl PartialOrd for StacksAddress {
592592
impl Ord for StacksAddress {
593593
fn cmp(&self, other: &StacksAddress) -> Ordering {
594594
match self.version().cmp(&other.version()) {
595-
Ordering::Equal => self.bytes().cmp(&other.bytes()),
595+
Ordering::Equal => self.bytes().cmp(other.bytes()),
596596
inequality => inequality,
597597
}
598598
}

stackslib/src/burnchains/affirmation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ pub fn read_prepare_phase_commits<B: BurnchainHeaderReader>(
557557

558558
let mut ret = vec![];
559559
for header in headers.into_iter() {
560-
let blk = BurnchainDB::get_burnchain_block(&burnchain_tx.conn(), &header.block_hash)
560+
let blk = BurnchainDB::get_burnchain_block(burnchain_tx.conn(), &header.block_hash)
561561
.unwrap_or_else(|_| {
562562
panic!(
563563
"BUG: failed to load prepare-phase block {} ({})",
@@ -1126,7 +1126,7 @@ pub fn find_pox_anchor_block<B: BurnchainHeaderReader>(
11261126
let prepare_ops_valid =
11271127
inner_find_valid_prepare_phase_commits(burnchain_tx, reward_cycle, indexer, burnchain)?;
11281128
let anchor_block_and_descendancy_opt = find_heaviest_block_commit(
1129-
&burnchain_tx,
1129+
burnchain_tx,
11301130
indexer,
11311131
&prepare_ops_valid,
11321132
burnchain.pox_constants.anchor_threshold,

stackslib/src/burnchains/bitcoin/address.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl SegwitBitcoinAddress {
290290
let mut bytes_u5: Vec<u5> = vec![u5::try_from_u8(self.witness_version())
291291
.expect("FATAL: bad witness version does not fit into a u5")];
292292
bytes_u5.extend_from_slice(&bytes.to_base32());
293-
let addr = bech32::encode(&hrp, bytes_u5, self.bech32_variant())
293+
let addr = bech32::encode(hrp, bytes_u5, self.bech32_variant())
294294
.expect("FATAL: could not encode segwit address");
295295
addr
296296
}

stackslib/src/burnchains/bitcoin/bits.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl BitcoinTxInputStructured {
5959
let i2 = &instructions[1];
6060

6161
match (i1, i2) {
62-
(Instruction::PushBytes(ref _data1), Instruction::PushBytes(ref data2)) => {
62+
(Instruction::PushBytes(_data1), Instruction::PushBytes(data2)) => {
6363
// data2 is a pubkey?
6464
match BitcoinPublicKey::from_slice(data2) {
6565
Ok(pubkey) => {
@@ -1274,7 +1274,7 @@ mod tests {
12741274
let raw_in = BitcoinTxInputRaw::from_bitcoin_witness_script_sig(
12751275
&txin.script_sig,
12761276
txin.witness.clone(),
1277-
to_txid(&txin),
1277+
to_txid(txin),
12781278
);
12791279
assert_eq!(raw_in, inputs[i]);
12801280
}
@@ -1287,7 +1287,7 @@ mod tests {
12871287
}
12881288

12891289
let segwit_out =
1290-
BitcoinTxOutput::from_bitcoin_txout(BitcoinNetworkType::Mainnet, &txout)
1290+
BitcoinTxOutput::from_bitcoin_txout(BitcoinNetworkType::Mainnet, txout)
12911291
.unwrap();
12921292
assert_eq!(segwit_out, outputs[j]);
12931293
j += 1;

stackslib/src/burnchains/bitcoin/blocks.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,7 @@ impl BitcoinBlockParser {
251251
}
252252

253253
// block transactions must match header merkle root
254-
let tx_merkle_root =
255-
bitcoin_merkle_root(block.txdata.iter().map(|ref tx| tx.txid()).collect());
254+
let tx_merkle_root = bitcoin_merkle_root(block.txdata.iter().map(|tx| tx.txid()).collect());
256255

257256
if block.header.merkle_root != tx_merkle_root {
258257
return false;
@@ -273,15 +272,15 @@ impl BitcoinBlockParser {
273272
return None;
274273
}
275274

276-
let script_pieces = bits::parse_script(&data_output);
275+
let script_pieces = bits::parse_script(data_output);
277276
if script_pieces.len() != 2 {
278277
// not OP_RETURN <data>
279278
test_debug!("Data output does not encode a valid OP_RETURN");
280279
return None;
281280
}
282281

283282
match (&script_pieces[0], &script_pieces[1]) {
284-
(Instruction::Op(ref opcode), Instruction::PushBytes(ref data)) => {
283+
(Instruction::Op(ref opcode), Instruction::PushBytes(data)) => {
285284
if *opcode != btc_opcodes::OP_RETURN {
286285
test_debug!("Data output does not use a standard OP_RETURN");
287286
return None;
@@ -349,7 +348,7 @@ impl BitcoinBlockParser {
349348
fn parse_inputs_structured(tx: &Transaction) -> Option<Vec<BitcoinTxInput>> {
350349
let mut ret = vec![];
351350
for inp in &tx.input {
352-
match BitcoinTxInput::from_bitcoin_txin_structured(&inp) {
351+
match BitcoinTxInput::from_bitcoin_txin_structured(inp) {
353352
None => {
354353
test_debug!("Failed to parse input");
355354
return None;
@@ -367,7 +366,7 @@ impl BitcoinBlockParser {
367366
fn parse_inputs_raw(tx: &Transaction) -> Vec<BitcoinTxInput> {
368367
let mut ret = vec![];
369368
for inp in &tx.input {
370-
ret.push(BitcoinTxInput::from_bitcoin_txin_raw(&inp));
369+
ret.push(BitcoinTxInput::from_bitcoin_txin_raw(inp));
371370
}
372371
ret
373372
}
@@ -386,9 +385,9 @@ impl BitcoinBlockParser {
386385
let mut ret = vec![];
387386
for outp in &tx.output[1..tx.output.len()] {
388387
let out_opt = if BitcoinBlockParser::allow_segwit_outputs(epoch_id) {
389-
BitcoinTxOutput::from_bitcoin_txout(self.network_id, &outp)
388+
BitcoinTxOutput::from_bitcoin_txout(self.network_id, outp)
390389
} else {
391-
BitcoinTxOutput::from_bitcoin_txout_legacy(self.network_id, &outp)
390+
BitcoinTxOutput::from_bitcoin_txout_legacy(self.network_id, outp)
392391
};
393392
match out_opt {
394393
None => {
@@ -507,7 +506,7 @@ impl BitcoinBlockParser {
507506
}
508507

509508
// parse it
510-
let burn_block = self.parse_block(&block, height, epoch_id);
509+
let burn_block = self.parse_block(block, height, epoch_id);
511510
Some(burn_block)
512511
}
513512
}
@@ -523,7 +522,7 @@ impl BurnchainBlockParser for BitcoinBlockParser {
523522
match ipc_block.block_message {
524523
btc_message::NetworkMessage::Block(ref block) => {
525524
match self.process_block(
526-
&block,
525+
block,
527526
&ipc_block.header_data.block_header,
528527
ipc_block.header_data.block_height,
529528
epoch_id,

stackslib/src/burnchains/bitcoin/indexer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ impl BitcoinIndexer {
469469
network_id: BitcoinNetworkType,
470470
) -> Result<SpvClient, btc_error> {
471471
SpvClient::new_without_migration(
472-
&reorg_headers_path,
472+
reorg_headers_path,
473473
start_block,
474474
end_block,
475475
network_id,
@@ -486,7 +486,7 @@ impl BitcoinIndexer {
486486
network_id: BitcoinNetworkType,
487487
) -> Result<SpvClient, btc_error> {
488488
SpvClient::new(
489-
&reorg_headers_path,
489+
reorg_headers_path,
490490
start_block,
491491
end_block,
492492
network_id,
@@ -3472,7 +3472,7 @@ mod test {
34723472

34733473
// set up SPV client so we don't have chain work at first
34743474
let mut spv_client = SpvClient::new_without_migration(
3475-
&db_path,
3475+
db_path,
34763476
0,
34773477
None,
34783478
BitcoinNetworkType::Regtest,

stackslib/src/burnchains/bitcoin/spv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,13 +722,13 @@ impl SpvClient {
722722
.next()
723723
.map_err(|e| btc_error::DBError(db_error::SqliteError(e)))?
724724
{
725-
let height: u64 = u64::from_column(&row, "height")?;
725+
let height: u64 = u64::from_column(row, "height")?;
726726
if height != next_height {
727727
break;
728728
}
729729
next_height += 1;
730730

731-
let next_header = BlockHeader::from_row(&row)?;
731+
let next_header = BlockHeader::from_row(row)?;
732732
headers.push(LoneBlockHeader {
733733
header: next_header,
734734
tx_count: VarInt(0),

stackslib/src/burnchains/burnchain.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl BurnchainStateTransition {
9898

9999
/// Get the transaction IDs of all accepted burnchain operations in this block
100100
pub fn txids(&self) -> Vec<Txid> {
101-
self.accepted_ops.iter().map(|ref op| op.txid()).collect()
101+
self.accepted_ops.iter().map(|op| op.txid()).collect()
102102
}
103103

104104
/// Get the sum of all burnchain tokens spent in this burnchain block's accepted operations
@@ -196,7 +196,7 @@ impl BurnchainStateTransition {
196196

197197
// find all VRF leader keys that were consumed by the block commits of this block
198198
let consumed_leader_keys =
199-
sort_tx.get_consumed_leader_keys(&parent_snapshot, &block_commits)?;
199+
sort_tx.get_consumed_leader_keys(parent_snapshot, &block_commits)?;
200200

201201
// assemble the commit windows
202202
let mut windowed_block_commits = vec![block_commits];
@@ -354,7 +354,7 @@ impl BurnchainStateTransition {
354354
);
355355
}
356356

357-
accepted_ops.sort_by(|ref a, ref b| a.vtxindex().partial_cmp(&b.vtxindex()).unwrap());
357+
accepted_ops.sort_by(|a, b| a.vtxindex().partial_cmp(&b.vtxindex()).unwrap());
358358

359359
Ok(BurnchainStateTransition {
360360
burn_dist,
@@ -424,7 +424,7 @@ impl BurnchainBlock {
424424
BurnchainBlock::Bitcoin(ref data) => data
425425
.txs
426426
.iter()
427-
.map(|ref tx| BurnchainTransaction::Bitcoin((*tx).clone()))
427+
.map(|tx| BurnchainTransaction::Bitcoin((*tx).clone()))
428428
.collect(),
429429
}
430430
}
@@ -849,7 +849,7 @@ impl Burnchain {
849849
}
850850
x if x == Opcodes::TransferStx as u8 => {
851851
let pre_stx_txid = TransferStxOp::get_sender_txid(burn_tx).ok()?;
852-
let pre_stx_tx = match pre_stx_op_map.get(&pre_stx_txid) {
852+
let pre_stx_tx = match pre_stx_op_map.get(pre_stx_txid) {
853853
Some(tx_ref) => Some(BlockstackOperationType::PreStx(tx_ref.clone())),
854854
None => burnchain_db.find_burnchain_op(indexer, pre_stx_txid),
855855
};
@@ -878,7 +878,7 @@ impl Burnchain {
878878
}
879879
x if x == Opcodes::StackStx as u8 => {
880880
let pre_stx_txid = StackStxOp::get_sender_txid(burn_tx).ok()?;
881-
let pre_stx_tx = match pre_stx_op_map.get(&pre_stx_txid) {
881+
let pre_stx_tx = match pre_stx_op_map.get(pre_stx_txid) {
882882
Some(tx_ref) => Some(BlockstackOperationType::PreStx(tx_ref.clone())),
883883
None => burnchain_db.find_burnchain_op(indexer, pre_stx_txid),
884884
};
@@ -913,7 +913,7 @@ impl Burnchain {
913913
}
914914
x if x == Opcodes::DelegateStx as u8 => {
915915
let pre_stx_txid = DelegateStxOp::get_sender_txid(burn_tx).ok()?;
916-
let pre_stx_tx = match pre_stx_op_map.get(&pre_stx_txid) {
916+
let pre_stx_tx = match pre_stx_op_map.get(pre_stx_txid) {
917917
Some(tx_ref) => Some(BlockstackOperationType::PreStx(tx_ref.clone())),
918918
None => burnchain_db.find_burnchain_op(indexer, pre_stx_txid),
919919
};
@@ -942,7 +942,7 @@ impl Burnchain {
942942
}
943943
x if x == Opcodes::VoteForAggregateKey as u8 => {
944944
let pre_stx_txid = VoteForAggregateKeyOp::get_sender_txid(burn_tx).ok()?;
945-
let pre_stx_tx = match pre_stx_op_map.get(&pre_stx_txid) {
945+
let pre_stx_tx = match pre_stx_op_map.get(pre_stx_txid) {
946946
Some(tx_ref) => Some(BlockstackOperationType::PreStx(tx_ref.clone())),
947947
None => burnchain_db.find_burnchain_op(indexer, pre_stx_txid),
948948
};
@@ -1038,7 +1038,7 @@ impl Burnchain {
10381038
);
10391039

10401040
let _blockstack_txs =
1041-
burnchain_db.store_new_burnchain_block(burnchain, indexer, &block, epoch_id)?;
1041+
burnchain_db.store_new_burnchain_block(burnchain, indexer, block, epoch_id)?;
10421042
Burnchain::process_affirmation_maps(
10431043
burnchain,
10441044
burnchain_db,
@@ -1110,7 +1110,7 @@ impl Burnchain {
11101110
let blockstack_txs = burnchain_db.store_new_burnchain_block(
11111111
burnchain,
11121112
indexer,
1113-
&block,
1113+
block,
11141114
cur_epoch.epoch_id,
11151115
)?;
11161116

stackslib/src/burnchains/db.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub(crate) fn apply_blockstack_txs_safety_checks(
152152
);
153153

154154
// safety -- make sure these are in order
155-
blockstack_txs.sort_by(|ref a, ref b| a.vtxindex().partial_cmp(&b.vtxindex()).unwrap());
155+
blockstack_txs.sort_by(|a, b| a.vtxindex().partial_cmp(&b.vtxindex()).unwrap());
156156

157157
// safety -- no duplicate vtxindex (shouldn't happen but crash if so)
158158
if blockstack_txs.len() > 1 {
@@ -349,7 +349,7 @@ impl BurnchainDBTransaction<'_> {
349349
let args = params![affirmation_map.encode(), u64_to_sql(weight)?];
350350
match self.sql_tx.execute(sql, args) {
351351
Ok(_) => {
352-
let am_id = BurnchainDB::get_affirmation_map_id(&self.sql_tx, &affirmation_map)?
352+
let am_id = BurnchainDB::get_affirmation_map_id(&self.sql_tx, affirmation_map)?
353353
.expect("BUG: no affirmation ID for affirmation map we just inserted");
354354
Ok(am_id)
355355
}
@@ -1231,7 +1231,7 @@ impl BurnchainDB {
12311231
self,
12321232
block_header,
12331233
epoch_id,
1234-
&tx,
1234+
tx,
12351235
&pre_stx_ops,
12361236
);
12371237
if let Some(classified_tx) = result {
@@ -1409,7 +1409,7 @@ impl BurnchainDB {
14091409
blockstack_ops.len()
14101410
);
14111411
db_tx.store_burnchain_db_entry(block_header)?;
1412-
db_tx.store_blockstack_ops(burnchain, indexer, &block_header, blockstack_ops)?;
1412+
db_tx.store_blockstack_ops(burnchain, indexer, block_header, blockstack_ops)?;
14131413

14141414
db_tx.commit()?;
14151415
Ok(())
@@ -1459,7 +1459,7 @@ impl BurnchainDB {
14591459
) -> Result<Option<LeaderBlockCommitOp>, DBError> {
14601460
let qry = "SELECT txid FROM block_commit_metadata WHERE block_height = ?1 AND vtxindex = ?2 AND burn_block_hash = ?3";
14611461
let args = params![block_ptr, vtxindex, header_hash];
1462-
let txid = match query_row(&conn, qry, args) {
1462+
let txid = match query_row(conn, qry, args) {
14631463
Ok(Some(txid)) => txid,
14641464
Ok(None) => {
14651465
test_debug!(

0 commit comments

Comments
 (0)