mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 09:21:04 +00:00
move AssignmentKind and CoreAssigment to scheduler (#1571)
This commit is contained in:
@@ -434,53 +434,6 @@ pub enum CoreOccupied {
|
||||
Parachain,
|
||||
}
|
||||
|
||||
/// The assignment type.
|
||||
#[derive(Clone, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(PartialEq, Debug))]
|
||||
pub enum AssignmentKind {
|
||||
/// A parachain.
|
||||
Parachain,
|
||||
/// A parathread.
|
||||
Parathread(CollatorId, u32),
|
||||
}
|
||||
|
||||
/// How a free core is scheduled to be assigned.
|
||||
#[derive(Clone, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(PartialEq, Debug))]
|
||||
pub struct CoreAssignment {
|
||||
/// The core that is assigned.
|
||||
pub core: CoreIndex,
|
||||
/// The unique ID of the para that is assigned to the core.
|
||||
pub para_id: Id,
|
||||
/// The kind of the assignment.
|
||||
pub kind: AssignmentKind,
|
||||
/// The index of the validator group assigned to the core.
|
||||
pub group_idx: GroupIndex,
|
||||
}
|
||||
|
||||
impl CoreAssignment {
|
||||
/// Get the ID of a collator who is required to collate this block.
|
||||
pub fn required_collator(&self) -> Option<&CollatorId> {
|
||||
match self.kind {
|
||||
AssignmentKind::Parachain => None,
|
||||
AssignmentKind::Parathread(ref id, _) => Some(id),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the `CoreOccupied` from this.
|
||||
pub fn to_core_occupied(&self) -> CoreOccupied {
|
||||
match self.kind {
|
||||
AssignmentKind::Parachain => CoreOccupied::Parachain,
|
||||
AssignmentKind::Parathread(ref collator, retries) => CoreOccupied::Parathread(
|
||||
ParathreadEntry {
|
||||
claim: ParathreadClaim(self.para_id, collator.clone()),
|
||||
retries,
|
||||
}
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Validation data omitted from most candidate descriptor structs, as it can be derived from the
|
||||
/// relay-parent.
|
||||
#[derive(Clone, Encode, Decode)]
|
||||
|
||||
Reference in New Issue
Block a user