Skip to content

Commit d8be6a2

Browse files
committed
chore: Apply Clippy lint iter_kv_map
1 parent 3dd68dd commit d8be6a2

File tree

8 files changed

+27
-35
lines changed

8 files changed

+27
-35
lines changed

stackslib/src/burnchains/affirmation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ pub fn read_parent_block_commits<B: BurnchainHeaderReader>(
679679
}
680680
}
681681
}
682-
let mut parent_list: Vec<_> = parents.into_iter().map(|(_, cmt)| cmt).collect();
682+
let mut parent_list: Vec<_> = parents.into_values().collect();
683683
parent_list.sort_by(|a, b| {
684684
if a.block_height != b.block_height {
685685
a.block_height.cmp(&b.block_height)

stackslib/src/burnchains/db.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,8 +1245,8 @@ impl BurnchainDB {
12451245

12461246
ops.extend(
12471247
pre_stx_ops
1248-
.into_iter()
1249-
.map(|(_, op)| BlockstackOperationType::PreStx(op)),
1248+
.into_values()
1249+
.map(BlockstackOperationType::PreStx),
12501250
);
12511251

12521252
ops.sort_by_key(|op| op.vtxindex());

stackslib/src/chainstate/stacks/miner.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,7 @@ pub struct MinerEpochInfo<'a> {
262262

263263
impl From<&UnconfirmedState> for MicroblockMinerRuntime {
264264
fn from(unconfirmed: &UnconfirmedState) -> MicroblockMinerRuntime {
265-
let considered = unconfirmed
266-
.mined_txs
267-
.iter()
268-
.map(|(txid, _)| txid.clone())
269-
.collect();
265+
let considered = unconfirmed.mined_txs.keys().cloned().collect();
270266
MicroblockMinerRuntime {
271267
bytes_so_far: unconfirmed.bytes_so_far,
272268
prev_microblock_header: unconfirmed.last_mblock.clone(),

stackslib/src/net/atlas/download.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@ impl AttachmentsBatchStateContext {
533533
}
534534
let mut events_ids = results
535535
.faulty_peers
536-
.iter()
537-
.map(|(k, _)| *k)
536+
.keys()
537+
.map(|k| *k)
538538
.collect::<Vec<usize>>();
539539
self.events_to_deregister.append(&mut events_ids);
540540

@@ -567,8 +567,8 @@ impl AttachmentsBatchStateContext {
567567
}
568568
let mut events_ids = results
569569
.faulty_peers
570-
.iter()
571-
.map(|(k, _)| *k)
570+
.keys()
571+
.map(|k| *k)
572572
.collect::<Vec<usize>>();
573573
self.events_to_deregister.append(&mut events_ids);
574574

stackslib/src/net/download/nakamoto/download_state_machine.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,8 +1402,7 @@ impl NakamotoDownloadStateMachine {
14021402
let tenure_blocks = coalesced_blocks
14031403
.into_iter()
14041404
.map(|(consensus_hash, block_map)| {
1405-
let mut block_list: Vec<_> =
1406-
block_map.into_iter().map(|(_, block)| block).collect();
1405+
let mut block_list: Vec<_> = block_map.into_values().collect();
14071406
block_list.sort_unstable_by_key(|blk| blk.header.chain_length);
14081407
(consensus_hash, block_list)
14091408
})

stackslib/src/net/inv/nakamoto.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,8 @@ impl<NC: NeighborComms> NakamotoInvStateMachine<NC> {
750750
/// Highest reward cycle learned
751751
pub fn highest_reward_cycle(&self) -> u64 {
752752
self.inventories
753-
.iter()
754-
.map(|(_, inv)| inv.highest_reward_cycle())
753+
.values()
754+
.map(|inv| inv.highest_reward_cycle())
755755
.max()
756756
.unwrap_or(0)
757757
}

stackslib/src/net/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,8 +1580,8 @@ impl NetworkResult {
15801580

15811581
let pushed_blocks: HashSet<_> = self
15821582
.pushed_blocks
1583-
.iter()
1584-
.map(|(_, block_list)| {
1583+
.values()
1584+
.map(|block_list| {
15851585
block_list
15861586
.iter()
15871587
.map(|block_data| {
@@ -1626,8 +1626,8 @@ impl NetworkResult {
16261626

16271627
let pushed_microblocks: HashSet<_> = self
16281628
.pushed_microblocks
1629-
.iter()
1630-
.map(|(_, mblock_list)| {
1629+
.values()
1630+
.map(|mblock_list| {
16311631
mblock_list
16321632
.iter()
16331633
.map(|(_, mblock_data)| {
@@ -1657,14 +1657,14 @@ impl NetworkResult {
16571657
fn all_nakamoto_block_ids(&self) -> HashSet<StacksBlockId> {
16581658
let mut naka_block_ids: HashSet<_> = self
16591659
.nakamoto_blocks
1660-
.iter()
1661-
.map(|(_, nblk)| nblk.block_id())
1660+
.values()
1661+
.map(|nblk| nblk.block_id())
16621662
.collect();
16631663

16641664
let pushed_nakamoto_blocks: HashSet<_> = self
16651665
.pushed_nakamoto_blocks
1666-
.iter()
1667-
.map(|(_, naka_blocks_list)| {
1666+
.values()
1667+
.map(|naka_blocks_list| {
16681668
naka_blocks_list
16691669
.iter()
16701670
.map(|(_, naka_blocks)| {
@@ -1705,8 +1705,8 @@ impl NetworkResult {
17051705
.collect();
17061706
let pushed_txids: HashSet<_> = self
17071707
.pushed_transactions
1708-
.iter()
1709-
.map(|(_, tx_list)| {
1708+
.values()
1709+
.map(|tx_list| {
17101710
tx_list
17111711
.iter()
17121712
.map(|(_, tx)| tx.txid())
@@ -1734,8 +1734,8 @@ impl NetworkResult {
17341734
/// This is unique per message.
17351735
fn all_msg_sigs(&self) -> HashSet<MessageSignature> {
17361736
self.unhandled_messages
1737-
.iter()
1738-
.map(|(_, msgs)| {
1737+
.values()
1738+
.map(|msgs| {
17391739
msgs.iter()
17401740
.map(|msg| msg.preamble.signature.clone())
17411741
.collect::<HashSet<_>>()

stackslib/src/net/relay.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,21 +2607,18 @@ impl Relayer {
26072607
new_microblocks: Vec<(Vec<RelayData>, MicroblocksData)>,
26082608
) {
26092609
// have the p2p thread tell our neighbors about newly-discovered blocks
2610-
let new_block_chs = new_blocks.iter().map(|(ch, _)| ch.clone()).collect();
2610+
let new_block_chs = new_blocks.keys().cloned().collect();
26112611
let available = Relayer::load_blocks_available_data(sortdb, new_block_chs)
26122612
.unwrap_or(BlocksAvailableMap::new());
26132613
if !available.is_empty() {
26142614
debug!("{:?}: Blocks available: {}", &_local_peer, available.len());
26152615
if let Err(e) = self.p2p.advertize_blocks(available, new_blocks) {
2616-
warn!("Failed to advertize new blocks: {:?}", &e);
2616+
warn!("Failed to advertize new blocks: {e:?}");
26172617
}
26182618
}
26192619

26202620
// have the p2p thread tell our neighbors about newly-discovered confirmed microblock streams
2621-
let new_mblock_chs = new_confirmed_microblocks
2622-
.iter()
2623-
.map(|(ch, _)| ch.clone())
2624-
.collect();
2621+
let new_mblock_chs = new_confirmed_microblocks.keys().cloned().collect();
26252622
let mblocks_available = Relayer::load_blocks_available_data(sortdb, new_mblock_chs)
26262623
.unwrap_or(BlocksAvailableMap::new());
26272624
if !mblocks_available.is_empty() {
@@ -2634,7 +2631,7 @@ impl Relayer {
26342631
.p2p
26352632
.advertize_microblocks(mblocks_available, new_confirmed_microblocks)
26362633
{
2637-
warn!("Failed to advertize new confirmed microblocks: {:?}", &e);
2634+
warn!("Failed to advertize new confirmed microblocks: {e:?}");
26382635
}
26392636
}
26402637

0 commit comments

Comments
 (0)