referrerpolicy=no-referrer-when-downgrade

Market

Trait Market 

Source
pub trait Market<RelayBlockNumber, Balance, AccountId> {
    type Error: Into<DispatchError>;
    type BidId: Copy + Debug + Codec + MaxEncodedLen + TypeInfo + Eq;
    type InitData: Parameter;
    type Configuration: Parameter;
    type CoreRangeProvider: CoreRangeProvider;
    type TimesliceProvider: TimesliceProvider;

    // Required methods
    fn configure(configuration: Self::Configuration) -> Result<(), Self::Error>;
    fn start_sales(
        block_number: RelayBlockNumber,
        init_data: Self::InitData,
    ) -> Result<SalesStarted<RelayBlockNumber>, Self::Error>;
    fn place_order(
        block_number: RelayBlockNumber,
        who: &AccountId,
        price_limit: Balance,
    ) -> Result<OrderResult<Balance, Self::BidId>, Self::Error>;
    fn place_renewal_order(
        block_number: RelayBlockNumber,
        who: &AccountId,
        renewal: PotentialRenewalId,
    ) -> Result<RenewalOrderResult<Balance, Self::BidId>, Self::Error>;
    fn adjust_bid(
        block_number: RelayBlockNumber,
        id: Self::BidId,
        who: &AccountId,
        new_price: Option<Balance>,
    ) -> Result<AdjustBidResult<Balance>, Self::Error>;
    fn tick(
        now: RelayBlockNumber,
        weight_meter: &mut WeightMeter,
    ) -> Vec<TickAction<AccountId, Balance, RelayBlockNumber>>;
}
Expand description

Trait representing generic coretime market logic.

§Assumptions about the market implementations

  • There are two types of orders: purchase and renewal.
  • Every successful order either creates a bid or is resolved immediately.
  • Coretime regions are equivalent from the user’s perspective.

§Market lifecycle

  1. Market::start_sales — initializes the market (if required).
  2. Market::place_order, Market::place_renewal_order, and Market::adjust_bid — users purchase or bid for coretime regions and renew existing ones.
  3. Market::tick — called from on_initialize hook to execute time-dependent logic.

Required Associated Types§

Source

type Error: Into<DispatchError>

Error type returned by market operations.

Source

type BidId: Copy + Debug + Codec + MaxEncodedLen + TypeInfo + Eq

Unique identifier assigned to each bid.

Source

type InitData: Parameter

Initialization data used in Market::start_sales.

Source

type Configuration: Parameter

Configuration of the market.

Can be set in the Market::configure.

Source

type CoreRangeProvider: CoreRangeProvider

Provides information about available cores.

Source

type TimesliceProvider: TimesliceProvider

Provides information about timeslice scheduling.

Required Methods§

Source

fn configure(configuration: Self::Configuration) -> Result<(), Self::Error>

Set or update the market configuration.

§Parameters
  • configuration: a new configuration to use.
Source

fn start_sales( block_number: RelayBlockNumber, init_data: Self::InitData, ) -> Result<SalesStarted<RelayBlockNumber>, Self::Error>

Start the coretime sales.

§Parameters
  • block_number: Current relay chain block number.
  • init_data: Market-specific initialization data.
Source

fn place_order( block_number: RelayBlockNumber, who: &AccountId, price_limit: Balance, ) -> Result<OrderResult<Balance, Self::BidId>, Self::Error>

Place an order to purchase one coretime region.

Depending on the implementation, this either: places a bid, or immediately executes the purchase.

§Parameters
  • block_number: Current relay chain block number.
  • who: Account placing the order.
  • price_limit: Maximum price the buyer is willing to pay.
Source

fn place_renewal_order( block_number: RelayBlockNumber, who: &AccountId, renewal: PotentialRenewalId, ) -> Result<RenewalOrderResult<Balance, Self::BidId>, Self::Error>

Place an order to renew a coretime region.

Depending on the implementation, this either: places a bid, or immediately executes the purchase.

§Parameters
  • block_number: Current relay chain block number.
  • who: Account placing the order.
  • renewal: Renewal identifier.
Source

fn adjust_bid( block_number: RelayBlockNumber, id: Self::BidId, who: &AccountId, new_price: Option<Balance>, ) -> Result<AdjustBidResult<Balance>, Self::Error>

Adjust the price of an existing bid.

This call may fail if the market does not allow increasing, decreasing, or withdrawing bids.

§Parameters
  • block_number: Current relay chain block number.
  • id: The identifier of the bid to adjust.
  • who: Account adjusting the bid.
  • new_price: The new bid price. If None is provided, the bid will be withdrawn.
Source

fn tick( now: RelayBlockNumber, weight_meter: &mut WeightMeter, ) -> Vec<TickAction<AccountId, Balance, RelayBlockNumber>>

Execute time-based market logic.

This function is called from the on_initialize hook by pallet-broker.

§Parameters
  • now: Current relay chain block number.
  • weight_meter: Used for advanced weight accounting.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§