pub trait Service {
// Required methods
fn refine(
core_index: CoreIndex,
item_index: usize,
service_id: ServiceId,
payload: WorkPayload,
package_hash: WorkPackageHash,
) -> WorkOutput;
fn accumulate(
slot: Slot,
service_id: ServiceId,
item_count: usize,
) -> Option<Hash>;
}Expand description
The invocation trait for a JAM service.
The declare_service macro requires that its parameter implement this trait.
Required Methods§
Sourcefn refine(
core_index: CoreIndex,
item_index: usize,
service_id: ServiceId,
payload: WorkPayload,
package_hash: WorkPackageHash,
) -> WorkOutput
fn refine( core_index: CoreIndex, item_index: usize, service_id: ServiceId, payload: WorkPayload, package_hash: WorkPackageHash, ) -> WorkOutput
The Refine entry-point, used in-core on a single Work Item.
core_index: The index of the core processing the work item.item_index: The index of the current work item.service_id: The index of the service being refined.payload: The payload data to process.package_hash: The hash of the Work Package.
Returns the Work Output, which will be passed into Self::accumulate in the on-chain (stateful) context.
Sourcefn accumulate(
slot: Slot,
service_id: ServiceId,
item_count: usize,
) -> Option<Hash>
fn accumulate( slot: Slot, service_id: ServiceId, item_count: usize, ) -> Option<Hash>
The Accumulate entry-point, used on-chain on one or more Work Item Outputs or Transfers, or possibly none in the case of an always-accumulate service.
slot: The current time slot.service_id: The service ID being accumulated.item_count: The number of items to accumulate. May be Work Outputs or Transfers.
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.