jam.types.work.item module

Work item types for the JAM protocol.

class jam.types.work.item.ImportSpec(tree_root: ByteArray32, index: U16)[source]

Bases: Codable, JsonSerde

Import specification structure.

tree_root: ByteArray32
index: U16
__init__(tree_root: ByteArray32, index: U16) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.work.item.ExtrinsicSpec(hash: ByteArray32, len: U32)[source]

Bases: Codable, JsonSerde

Extrinsic specification structure.

hash: ByteArray32
len: U32
__init__(hash: ByteArray32, len: U32) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.

class jam.types.work.item.ImportSpecs(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Vector[ImportSpec]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Vector[T], int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.work.item.ExtrinsicSpecs(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Vector[ExtrinsicSpec]

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[Vector[T], int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

class jam.types.work.item.WorkItem(service: U32, code_hash: ByteArray32, payload: Bytes, refine_gas_limit: U64, accumulate_gas_limit: U64, import_segments: ImportSpecs, extrinsic: ExtrinsicSpecs, export_count: U16)[source]

Bases: Codable, JsonSerde

Work item structure.

service: U32
code_hash: ByteArray32
payload: Bytes
refine_gas_limit: U64
accumulate_gas_limit: U64
import_segments: ImportSpecs
extrinsic: ExtrinsicSpecs
export_count: U16
__init__(service: U32, code_hash: ByteArray32, payload: Bytes, refine_gas_limit: U64, accumulate_gas_limit: U64, import_segments: ImportSpecs, extrinsic: ExtrinsicSpecs, export_count: U16) None

Initialize the Codable.

Parameters:
  • codec – Optional codec to use for encoding/decoding

  • enc_sequence – Optional function that returns sequence of fields to encode

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[T, int]

Decode from buffer. Must be implemented by subclasses or added via decorator.

Parameters:
  • buffer – Buffer to decode from

  • offset – Starting position in buffer

Returns:

  • The decoded value

  • Number of bytes read

Return type:

Tuple containing

encode_into(buffer: bytearray, offset: int = 0) int

Encode into provided buffer.

encode_size() int

Calculate number of bytes needed to encode.