#![deny(missing_docs)]
use alloc::vec::Vec;
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
use core::fmt::Debug;
use pezframe_support::Parameter;
use pezsp_arithmetic::traits::AtLeast32BitUnsigned;
use pezsp_core::RuntimeDebug;
use pezsp_runtime::traits::BlockNumberProvider;
use scale_info::TypeInfo;
use crate::Timeslice;
pub type CoreIndex = u16;
pub type TaskId = u32;
pub type PartsOf57600 = u16;
#[derive(
Encode,
Decode,
DecodeWithMemTracking,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
RuntimeDebug,
TypeInfo,
MaxEncodedLen,
)]
pub enum CoreAssignment {
Idle,
Pool,
Task(TaskId),
}
pub type RCBlockNumberOf<T> = <RCBlockNumberProviderOf<T> as BlockNumberProvider>::BlockNumber;
pub type RCBlockNumberProviderOf<T> = <T as CoretimeInterface>::RelayChainBlockNumberProvider;
pub trait CoretimeInterface {
type AccountId: Parameter;
type Balance: AtLeast32BitUnsigned + Encode + Decode + MaxEncodedLen + TypeInfo + Debug;
type RelayChainBlockNumberProvider: BlockNumberProvider;
fn request_core_count(count: CoreIndex);
fn request_revenue_info_at(when: RCBlockNumberOf<Self>);
fn credit_account(who: Self::AccountId, amount: Self::Balance);
fn assign_core(
core: CoreIndex,
begin: RCBlockNumberOf<Self>,
assignment: Vec<(CoreAssignment, PartsOf57600)>,
end_hint: Option<RCBlockNumberOf<Self>>,
);
fn on_new_timeslice(_timeslice: Timeslice) {}
}
impl CoretimeInterface for () {
type AccountId = ();
type Balance = u64;
type RelayChainBlockNumberProvider = ();
fn request_core_count(_count: CoreIndex) {}
fn request_revenue_info_at(_when: RCBlockNumberOf<Self>) {}
fn credit_account(_who: Self::AccountId, _amount: Self::Balance) {}
fn assign_core(
_core: CoreIndex,
_begin: RCBlockNumberOf<Self>,
_assignment: Vec<(CoreAssignment, PartsOf57600)>,
_end_hint: Option<RCBlockNumberOf<Self>>,
) {
}
}