jam_pvm_common

Trait Service

Source
pub trait Service {
    // Required methods
    fn refine(
        id: ServiceId,
        payload: WorkPayload,
        package_info: PackageInfo,
        extrinsics: Vec<Vec<u8>>,
    ) -> WorkOutput;
    fn accumulate(slot: Slot, id: ServiceId, results: Vec<AccumulateItem>);
    fn on_transfer(slot: Slot, id: ServiceId, transfers: Vec<TransferRecord>);
}
Expand description

The invocation trait for a JAM service.

The declare_service macro requires that its parameter implement this trait.

Required Methods§

Source

fn refine( id: ServiceId, payload: WorkPayload, package_info: PackageInfo, extrinsics: Vec<Vec<u8>>, ) -> WorkOutput

The Refine entry-point, used in-core on a single Work Item.

  • id: The service ID of the Work Item.
  • payload: The payload data within the Work Item.
  • package_info: Information concerning the Work Package in which the Work Item sits.
  • extrinsics: The extrinsic data associated with the Work Item.

Returns the Work Output, which will be passed into Self::accumulate in the on-chain (stateful) context.

Source

fn accumulate(slot: Slot, id: ServiceId, results: Vec<AccumulateItem>)

The Accumulate entry-point, used on-chain on one or more Work Item Outputs, or possibly none in the case of an always-accumulate service.

  • context: The current time slot and service ID being accumulated.
  • results: The Work Outputs of the Work Items, together with additional information on the Work Packages which brought them about.
Source

fn on_transfer(slot: Slot, id: ServiceId, transfers: Vec<TransferRecord>)

The On Transfer entry-point, used on-chain on one or more Transfers.

  • context: The current time slot and service ID being accumulated.
  • transfers: Information on the Transfers to the service ID in question.

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§