babe: minor rpc nits (#5974)

* babe: fix formatting

* babe: re-use same epoch data in epoch_authorship rpc method
This commit is contained in:
André Silva
2020-05-12 14:18:15 +01:00
committed by GitHub
parent 3a8b40ebda
commit c91e681db2
@@ -118,15 +118,18 @@ impl<B, C, SC> BabeApi for BabeRPCHandler<B, C, SC>
let key_pairs = { let key_pairs = {
let keystore = keystore.read(); let keystore = keystore.read();
epoch.authorities.iter().enumerate() epoch.authorities.iter()
.flat_map(|(i, a)| { .enumerate()
keystore.key_pair::<sp_consensus_babe::AuthorityPair>(&a.0).ok().map(|kp| (kp, i)) .flat_map(|(i, a)| {
}) keystore
.collect::<Vec<_>>() .key_pair::<sp_consensus_babe::AuthorityPair>(&a.0)
.ok()
.map(|kp| (kp, i))
})
.collect::<Vec<_>>()
}; };
for slot_number in epoch_start..epoch_end { for slot_number in epoch_start..epoch_end {
let epoch = epoch_data(&shared_epoch, &client, &babe_config, slot_number, &select_chain)?;
if let Some((claim, key)) = if let Some((claim, key)) =
authorship::claim_slot_using_key_pairs(slot_number, &epoch, &key_pairs) authorship::claim_slot_using_key_pairs(slot_number, &epoch, &key_pairs)
{ {