Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
better var names
  • Loading branch information
drahnr committed Oct 2, 2021
commit 3d3f471a89232274e645d4da2adadc0d70d24d8d
19 changes: 12 additions & 7 deletions runtime/parachains/src/inclusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ impl<T: Config> Pallet<T> {

/// Process a set of incoming bitfields. Return a `vec` of cores freed by candidates
/// becoming available.
///
/// Returns a set of `CandidateHash`es and their respective `AvailabilityCore`s that became available,
/// and cores free.
pub(crate) fn process_bitfields(
expected_bits: usize,
unchecked_bitfields: UncheckedSignedAvailabilityBitfields,
Expand All @@ -250,10 +253,12 @@ impl<T: Config> Pallet<T> {
let validators = shared::Pallet::<T>::active_validator_keys();
let session_index = shared::Pallet::<T>::session_index();

let mut assigned_paras_record: Vec<_> = (0..expected_bits)
let mut assigned_paras_record = (0..expected_bits)
.map(|bit_index| core_lookup(CoreIndex::from(bit_index as u32)))
.map(|core_para| core_para.map(|p| (p, PendingAvailability::<T>::get(&p))))
.collect();
.map(|opt_para_id| {
opt_para_id.map(|para_id| (para_id, PendingAvailability::<T>::get(&para_id)))
})
.collect::<Vec<_>>();

// do sanity checks on the bitfields:
// 1. no more than one bitfield per validator
Expand Down Expand Up @@ -333,10 +338,10 @@ impl<T: Config> Pallet<T> {
// defensive check - this is constructed by loading the availability bitfield record,
// which is always `Some` if the core is occupied - that's why we're here.
let val_idx = signed_bitfield.validator_index().0 as usize;
if let Some(mut bit) = pending_availability
.as_mut()
.and_then(|r| r.availability_votes.get_mut(val_idx))
{
if let Some(mut bit) =
pending_availability.as_mut().and_then(|candidate_pending_availability| {
candidate_pending_availability.availability_votes.get_mut(val_idx)
}) {
*bit = true;
} else if cfg!(debug_assertions) {
ensure!(false, Error::<T>::InternalError);
Expand Down