Skip to content

Commit 8a55dd4

Browse files
committed
chore: Apply Clippy lint redundant_clone manually
1 parent eccfec0 commit 8a55dd4

Some content is hidden

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

95 files changed

+933
-1387
lines changed

stackslib/src/burnchains/affirmation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ pub fn update_pox_affirmation_maps<B: BurnchainHeaderReader>(
11821182
let (prepare_ops, pox_anchor_block_info_opt) =
11831183
find_pox_anchor_block(&tx, reward_cycle, indexer, burnchain)?;
11841184

1185-
if let Some((anchor_block, descendancy)) = pox_anchor_block_info_opt.clone() {
1185+
if let Some((anchor_block, descendancy)) = pox_anchor_block_info_opt {
11861186
debug!(
11871187
"PoX anchor block elected in reward cycle {} for reward cycle {} is {}",
11881188
reward_cycle,

stackslib/src/burnchains/bitcoin/indexer.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,11 +1343,9 @@ mod test {
13431343
let mut spv_client_reorg =
13441344
SpvClient::new(path_2, 0, None, BitcoinNetworkType::Regtest, true, false).unwrap();
13451345

1346-
spv_client
1347-
.insert_block_headers_after(0, headers_1.clone())
1348-
.unwrap();
1346+
spv_client.insert_block_headers_after(0, headers_1).unwrap();
13491347
spv_client_reorg
1350-
.insert_block_headers_after(0, headers_2.clone())
1348+
.insert_block_headers_after(0, headers_2)
13511349
.unwrap();
13521350

13531351
spv_client.update_chain_work().unwrap();
@@ -1521,11 +1519,9 @@ mod test {
15211519
let mut spv_client_reorg =
15221520
SpvClient::new(path_2, 0, None, BitcoinNetworkType::Regtest, true, false).unwrap();
15231521

1524-
spv_client
1525-
.insert_block_headers_after(0, headers_1.clone())
1526-
.unwrap();
1522+
spv_client.insert_block_headers_after(0, headers_1).unwrap();
15271523
spv_client_reorg
1528-
.insert_block_headers_after(0, headers_2.clone())
1524+
.insert_block_headers_after(0, headers_2)
15291525
.unwrap();
15301526

15311527
assert_eq!(spv_client.read_block_headers(0, 10).unwrap().len(), 4);
@@ -3338,7 +3334,7 @@ mod test {
33383334

33393335
// put these bad headers into the "main" chain
33403336
spv_client
3341-
.insert_block_headers_after(40318, bad_headers.clone())
3337+
.insert_block_headers_after(40318, bad_headers)
33423338
.unwrap();
33433339

33443340
// *now* calculate main chain work
@@ -3485,9 +3481,7 @@ mod test {
34853481
)
34863482
.unwrap();
34873483

3488-
spv_client
3489-
.test_write_block_headers(0, headers.clone())
3490-
.unwrap();
3484+
spv_client.test_write_block_headers(0, headers).unwrap();
34913485
assert_eq!(spv_client.get_highest_header_height().unwrap(), 2);
34923486

34933487
let mut indexer = BitcoinIndexer::new(
@@ -3518,7 +3512,7 @@ mod test {
35183512

35193513
let should_keep_running = Arc::new(AtomicBool::new(true));
35203514
let mut indexer = BitcoinIndexer::new(
3521-
BitcoinIndexerConfig::test_default(db_path.to_string()),
3515+
BitcoinIndexerConfig::test_default(db_path),
35223516
BitcoinIndexerRuntime::new(BitcoinNetworkType::Mainnet),
35233517
Some(should_keep_running.clone()),
35243518
);

stackslib/src/burnchains/bitcoin/spv.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,7 @@ mod test {
16291629
.unwrap();
16301630
assert_eq!(spv_client.read_block_headers(1, 10).unwrap(), headers);
16311631

1632-
let mut all_headers = vec![genesis_regtest_header.clone()];
1632+
let mut all_headers = vec![genesis_regtest_header];
16331633
all_headers.append(&mut headers.clone());
16341634

16351635
assert_eq!(spv_client.read_block_headers(0, 10).unwrap(), all_headers);
@@ -1652,9 +1652,7 @@ mod test {
16521652
}
16531653

16541654
// should succeed
1655-
spv_client
1656-
.insert_block_headers_before(9, headers.clone())
1657-
.unwrap();
1655+
spv_client.insert_block_headers_before(9, headers).unwrap();
16581656
}
16591657

16601658
#[test]
@@ -1773,10 +1771,7 @@ mod test {
17731771
];
17741772

17751773
// should fail
1776-
if let btc_error::InvalidPoW = spv_client
1777-
.handle_headers(40317, bad_headers.clone())
1778-
.unwrap_err()
1779-
{
1774+
if let btc_error::InvalidPoW = spv_client.handle_headers(40317, bad_headers).unwrap_err() {
17801775
} else {
17811776
panic!("Bad PoW headers accepted");
17821777
}

stackslib/src/burnchains/tests/affirmation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ fn test_parent_block_commits() {
623623
// orphan
624624
assert_eq!(parent_commits.len(), all_ops_with_orphan.len() - 1);
625625

626-
let mut all_ops_with_same_parent = all_ops.clone();
626+
let mut all_ops_with_same_parent = all_ops;
627627
for ops in all_ops_with_same_parent.iter_mut() {
628628
for opdata in ops.iter_mut() {
629629
opdata.parent_block_ptr = 3;
@@ -950,7 +950,7 @@ fn test_find_heaviest_block_commit() {
950950
// X------- 4,0
951951
//
952952
// X------------ 5,0
953-
let mut all_ops_no_majority = filtered_ops.clone();
953+
let mut all_ops_no_majority = filtered_ops;
954954
all_ops_no_majority[0][0].parent_block_ptr = 2;
955955
all_ops_no_majority[0][0].parent_vtxindex = 10;
956956
all_ops_no_majority[0][0].burn_fee = 0;
@@ -1155,7 +1155,7 @@ fn test_find_heaviest_parent_commit_many_commits() {
11551155
// 1,0 <-- 2,0 <--- 3,0 <--- 4,0 <--- 5,0
11561156
// \
11571157
// `---- 2,1 <--- 3,1 <--- 4,1 <--- 5,1 (winner)
1158-
let mut all_ops_no_majority = filtered_ops.clone();
1158+
let mut all_ops_no_majority = filtered_ops;
11591159

11601160
// 3,0
11611161
all_ops_no_majority[0][0].parent_block_ptr = 2;

stackslib/src/burnchains/tests/burnchain.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,16 +428,12 @@ fn test_process_block_ops() {
428428
],
429429
vec![
430430
BlockstackOperationType::LeaderBlockCommit(block_commit_1.clone()),
431-
BlockstackOperationType::LeaderBlockCommit(block_commit_2.clone()),
431+
BlockstackOperationType::LeaderBlockCommit(block_commit_2),
432432
BlockstackOperationType::LeaderBlockCommit(block_commit_3.clone()),
433433
],
434434
];
435435

436-
let block_124_winners = vec![
437-
block_commit_1.clone(),
438-
block_commit_3.clone(),
439-
block_commit_1.clone(),
440-
];
436+
let block_124_winners = vec![block_commit_1.clone(), block_commit_3, block_commit_1];
441437

442438
let mut db = SortitionDB::connect_test(first_block_height, &first_burn_hash).unwrap();
443439

stackslib/src/burnchains/tests/db.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn test_store_and_fetch() {
147147
&BurnchainHeaderHash::sentinel()
148148
);
149149

150-
let headers = vec![first_block_header.clone()];
150+
let headers = vec![first_block_header];
151151
let canon_hash = BurnchainHeaderHash([1; 32]);
152152

153153
let canonical_block =
@@ -1098,7 +1098,7 @@ fn test_classify_delegate_stx() {
10981098

10991099
let canonical_block =
11001100
BurnchainBlock::Bitcoin(BitcoinBlock::new(500, &canon_hash, &first_bhh, vec![], 485));
1101-
let mut headers = vec![first_block_header.clone(), canonical_block.header().clone()];
1101+
let mut headers = vec![first_block_header, canonical_block.header()];
11021102

11031103
let ops = burnchain_db
11041104
.store_new_burnchain_block(
@@ -1291,8 +1291,8 @@ fn test_classify_delegate_stx() {
12911291
360,
12921292
));
12931293

1294-
headers.push(block_0.header().clone());
1295-
headers.push(block_1.header().clone());
1294+
headers.push(block_0.header());
1295+
headers.push(block_1.header());
12961296

12971297
test_debug!("store ops ({}) for block 0", ops_0_length);
12981298
let processed_ops_0 = burnchain_db

stackslib/src/chainstate/burn/db/processing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl SortitionHandleTx<'_> {
135135

136136
let next_pox = SortitionDB::make_next_pox_id(parent_pox.clone(), next_pox_info.as_ref());
137137
let next_sortition_id = SortitionDB::make_next_sortition_id(
138-
parent_pox.clone(),
138+
parent_pox,
139139
&this_block_hash,
140140
next_pox_info.as_ref(),
141141
);

stackslib/src/chainstate/burn/db/sortdb.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7335,9 +7335,9 @@ pub mod tests {
73357335
{
73367336
let mut ic = SortitionHandleTx::begin(&mut db, &snapshot.sortition_id).unwrap();
73377337
let keys = ic
7338-
.get_consumed_leader_keys(&fork_snapshot, &vec![block_commit.clone()])
7338+
.get_consumed_leader_keys(&fork_snapshot, &vec![block_commit])
73397339
.unwrap();
7340-
assert_eq!(keys, vec![leader_key.clone()]);
7340+
assert_eq!(keys, vec![leader_key]);
73417341
}
73427342
}
73437343

@@ -7386,9 +7386,7 @@ pub mod tests {
73867386
let key_snapshot = test_append_snapshot(
73877387
&mut db,
73887388
BurnchainHeaderHash([0x03; 32]),
7389-
&[BlockstackOperationType::LeaderKeyRegister(
7390-
leader_key.clone(),
7391-
)],
7389+
&[BlockstackOperationType::LeaderKeyRegister(leader_key)],
73927390
);
73937391

73947392
let has_key_after = {
@@ -7913,9 +7911,7 @@ pub mod tests {
79137911
let key_snapshot = test_append_snapshot(
79147912
&mut db,
79157913
BurnchainHeaderHash([0x01; 32]),
7916-
&[BlockstackOperationType::LeaderKeyRegister(
7917-
leader_key.clone(),
7918-
)],
7914+
&[BlockstackOperationType::LeaderKeyRegister(leader_key)],
79197915
);
79207916

79217917
let commit_snapshot = test_append_snapshot(
@@ -10259,9 +10255,7 @@ pub mod tests {
1025910255
let key_snapshot = test_append_snapshot(
1026010256
&mut db,
1026110257
BurnchainHeaderHash([0x01; 32]),
10262-
&[BlockstackOperationType::LeaderKeyRegister(
10263-
leader_key.clone(),
10264-
)],
10258+
&[BlockstackOperationType::LeaderKeyRegister(leader_key)],
1026510259
);
1026610260

1026710261
let genesis_commit_snapshot = test_append_snapshot_with_winner(

stackslib/src/chainstate/burn/distribution.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ mod tests {
785785
let mut result = BurnSamplePoint::make_min_median_distribution(
786786
MINING_COMMITMENT_WINDOW,
787787
commits.clone(),
788-
missed_commits.clone(),
788+
missed_commits,
789789
vec![false, false, false, false, false, false],
790790
);
791791

@@ -1261,11 +1261,7 @@ mod tests {
12611261
],
12621262
},
12631263
BurnDistFixture {
1264-
consumed_leader_keys: vec![
1265-
leader_key_1.clone(),
1266-
leader_key_2.clone(),
1267-
leader_key_3.clone(),
1268-
],
1264+
consumed_leader_keys: vec![leader_key_1, leader_key_2, leader_key_3],
12691265
block_commits: vec![
12701266
block_commit_1.clone(),
12711267
block_commit_2.clone(),
@@ -1283,7 +1279,7 @@ mod tests {
12831279
0x70989faf596c8b65,
12841280
0x41a3ed94d3cb0a84,
12851281
]),
1286-
candidate: block_commit_1.clone(),
1282+
candidate: block_commit_1,
12871283
},
12881284
BurnSamplePoint {
12891285
burns: block_commit_2.burn_fee.into(),
@@ -1301,7 +1297,7 @@ mod tests {
13011297
0xe1313f5eb2d916ca,
13021298
0x8347db29a7961508,
13031299
]),
1304-
candidate: block_commit_2.clone(),
1300+
candidate: block_commit_2,
13051301
},
13061302
BurnSamplePoint {
13071303
burns: (block_commit_3.burn_fee).into(),
@@ -1314,7 +1310,7 @@ mod tests {
13141310
0x8347db29a7961508,
13151311
]),
13161312
range_end: Uint256::max(),
1317-
candidate: block_commit_3.clone(),
1313+
candidate: block_commit_3,
13181314
},
13191315
],
13201316
},

stackslib/src/chainstate/burn/operations/delegate_stx.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ mod tests {
409409
let op = DelegateStxOp::parse_from_tx(
410410
16843022,
411411
&BurnchainHeaderHash([0; 32]),
412-
&BurnchainTransaction::Bitcoin(tx.clone()),
412+
&BurnchainTransaction::Bitcoin(tx),
413413
&sender,
414414
)
415415
.unwrap();
@@ -456,7 +456,7 @@ mod tests {
456456
let err = DelegateStxOp::parse_from_tx(
457457
16843022,
458458
&BurnchainHeaderHash([0; 32]),
459-
&BurnchainTransaction::Bitcoin(tx.clone()),
459+
&BurnchainTransaction::Bitcoin(tx),
460460
&sender,
461461
)
462462
.unwrap_err();
@@ -498,7 +498,7 @@ mod tests {
498498
let err = DelegateStxOp::parse_from_tx(
499499
16843022,
500500
&BurnchainHeaderHash([0; 32]),
501-
&BurnchainTransaction::Bitcoin(tx.clone()),
501+
&BurnchainTransaction::Bitcoin(tx),
502502
&sender,
503503
)
504504
.unwrap_err();
@@ -544,7 +544,7 @@ mod tests {
544544
let err = DelegateStxOp::parse_from_tx(
545545
16843022,
546546
&BurnchainHeaderHash([0; 32]),
547-
&BurnchainTransaction::Bitcoin(tx.clone()),
547+
&BurnchainTransaction::Bitcoin(tx),
548548
&sender,
549549
)
550550
.unwrap_err();
@@ -583,7 +583,7 @@ mod tests {
583583
let err = DelegateStxOp::parse_from_tx(
584584
16843022,
585585
&BurnchainHeaderHash([0; 32]),
586-
&BurnchainTransaction::Bitcoin(tx.clone()),
586+
&BurnchainTransaction::Bitcoin(tx),
587587
&sender,
588588
)
589589
.unwrap_err();

0 commit comments

Comments
 (0)