Skip to content

Commit e9c1ab8

Browse files
committed
chore: Minor refactoring
1 parent a46254d commit e9c1ab8

File tree

1 file changed

+10
-24
lines changed
  • stackslib/src/chainstate/stacks/tests

1 file changed

+10
-24
lines changed

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

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -967,40 +967,26 @@ pub fn get_last_microblock_header(
967967
miner: &TestMiner,
968968
parent_block_opt: Option<&StacksBlock>,
969969
) -> Option<StacksMicroblockHeader> {
970-
let last_microblocks_opt =
971-
parent_block_opt.and_then(|block| node.get_microblock_stream(miner, &block.block_hash()));
972-
973-
let last_microblock_header_opt = match last_microblocks_opt {
974-
Some(last_microblocks) => {
975-
if last_microblocks.is_empty() {
976-
None
977-
} else {
978-
let l = last_microblocks.len() - 1;
979-
Some(last_microblocks[l].header.clone())
980-
}
981-
}
982-
None => None,
983-
};
984-
985-
last_microblock_header_opt
970+
parent_block_opt
971+
.and_then(|block| node.get_microblock_stream(miner, &block.block_hash()))
972+
.as_ref()
973+
.and_then(|mblock_stream| mblock_stream.last())
974+
.map(|mblock| mblock.header.clone())
986975
}
987976

988977
pub fn get_all_mining_rewards(
989978
chainstate: &mut StacksChainState,
990979
tip: &StacksHeaderInfo,
991980
block_height: u64,
992981
) -> Vec<Vec<MinerPaymentSchedule>> {
993-
let mut ret = vec![];
994982
let mut tx = chainstate.index_tx_begin();
995983

996-
for i in 0..block_height {
997-
let block_rewards =
984+
(0..block_height)
985+
.map(|i| {
998986
StacksChainState::get_scheduled_block_rewards_in_fork_at_height(&mut tx, tip, i)
999-
.unwrap();
1000-
ret.push(block_rewards);
1001-
}
1002-
1003-
ret
987+
.unwrap()
988+
})
989+
.collect()
1004990
}
1005991

1006992
pub fn make_coinbase(miner: &mut TestMiner, burnchain_height: usize) -> StacksTransaction {

0 commit comments

Comments
 (0)