jam.types.work.package module

Work package types for the JAM protocol.

class jam.types.work.package.Authorizer(code_hash: ByteArray32, params: Bytes)[source]

Bases: Codable, JsonSerde

Authorizer structure.

code_hash: ByteArray32
params: Bytes
__init__(code_hash: ByteArray32, params: Bytes) 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.package.WorkItems(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]

Bases: Vector[WorkItem]

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.package.WorkPackage(authorization: Bytes, auth_code_host: U32, authorizer: Authorizer, context: RefineContext, items: WorkItems)[source]

Bases: Codable, JsonSerde

Work package structure.

authorization: Bytes
auth_code_host: U32
authorizer: Authorizer
context: RefineContext
items: WorkItems
__init__(authorization: Bytes, auth_code_host: U32, authorizer: Authorizer, context: RefineContext, items: WorkItems) 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.