Skip to content

Commit e45112a

Browse files
committed
CRC: cleanup
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent c3ccfb2 commit e45112a

File tree

5 files changed

+11
-18
lines changed

5 files changed

+11
-18
lines changed

stackslib/src/chainstate/stacks/db/blocks.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10020,8 +10020,9 @@ pub mod test {
1002010020
let block_hashes: Vec<BlockHeaderHash> = blocks.iter().map(|b| b.block_hash()).collect();
1002110021
let header_hashes_all: Vec<(ConsensusHash, Option<BlockHeaderHash>)> = consensus_hashes
1002210022
.iter()
10023-
.zip(block_hashes.iter())
10024-
.map(|(burn, block)| ((*burn).clone(), Some((*block).clone())))
10023+
.cloned()
10024+
.zip(block_hashes.iter().cloned())
10025+
.map(|(burn, block)| (burn, Some(block)))
1002510026
.collect();
1002610027

1002710028
// nothing is stored, so our inventory should be empty

stackslib/src/chainstate/stacks/tests/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -967,10 +967,8 @@ pub fn get_last_microblock_header(
967967
miner: &TestMiner,
968968
parent_block_opt: Option<&StacksBlock>,
969969
) -> Option<StacksMicroblockHeader> {
970-
let last_microblocks_opt = match parent_block_opt {
971-
Some(block) => node.get_microblock_stream(miner, &block.block_hash()),
972-
None => None,
973-
};
970+
let last_microblocks_opt =
971+
parent_block_opt.and_then(|block| node.get_microblock_stream(miner, &block.block_hash()));
974972

975973
let last_microblock_header_opt = match last_microblocks_opt {
976974
Some(last_microblocks) => {

stackslib/src/net/api/gettenure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl HttpRequest for RPCNakamotoTenureRequestHandler {
191191
.map(|last_block_id_hex| StacksBlockId::from_hex(last_block_id_hex))
192192
.transpose()
193193
.map_err(|e| {
194-
Error::DecodeError(format!("Failed to parse stop= query parameter: {:?}", &e))
194+
Error::DecodeError(format!("Failed to parse stop= query parameter: {e:?}"))
195195
})?;
196196

197197
self.last_block_id = last_block_id;

stackslib/src/net/p2p.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,13 +2280,10 @@ impl PeerNetwork {
22802280

22812281
/// Get stats for a neighbor
22822282
pub fn get_neighbor_stats(&self, nk: &NeighborKey) -> Option<NeighborStats> {
2283-
match self.events.get(nk) {
2284-
None => None,
2285-
Some(eid) => match self.peers.get(eid) {
2286-
None => None,
2287-
Some(convo) => Some(convo.stats.clone()),
2288-
},
2289-
}
2283+
self.events
2284+
.get(nk)
2285+
.and_then(|eid| self.peers.get(eid))
2286+
.map(|convo| convo.stats.clone())
22902287
}
22912288

22922289
/// Update peer connections as a result of a peer graph walk.

stackslib/src/net/tests/convergence.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,10 +861,7 @@ fn dump_peers(peers: &Vec<TestPeer>) {
861861
}
862862

863863
let all_neighbors = PeerDB::get_all_peers(peers[i].network.peerdb.conn()).unwrap();
864-
let num_allowed = all_neighbors.iter().fold(0, |mut sum, n2| {
865-
sum += if n2.allowed < 0 { 1 } else { 0 };
866-
sum
867-
});
864+
let num_allowed = all_neighbors.iter().filter(|n2| n2.allowed < 0).count();
868865
test_debug!("Neighbor {} (all={}, outbound={}) (total neighbors = {}, total allowed = {}): outbound={:?} all={:?}", i, neighbor_index.len(), outbound_neighbor_index.len(), all_neighbors.len(), num_allowed, &outbound_neighbor_index, &neighbor_index);
869866
}
870867
test_debug!("\n");

0 commit comments

Comments
 (0)