Skip to content

Module dev_scheduler_formats.erl

This module is used by dev_scheduler in order to produce outputs that are compatible with various forms of AO clients.

Description

It features two main formats:

  • application/json
  • application/http

The application/json format is a legacy format that is not recommended for new integrations of the AO protocol.

Function Index

aos2_normalize_data/1*The hb_gateway_client module expects all JSON structures to at least have a data field.
aos2_normalize_types/1Normalize an AOS2 formatted message to ensure that all field NAMES and types are correct.
aos2_to_assignment/2Create and normalize an assignment from an AOS2-style JSON structure.
aos2_to_assignments/3Convert an AOS2-style JSON structure to a normalized HyperBEAM assignments response.
assignment_to_aos2/2*Convert an assignment to an AOS2-compatible JSON structure.
assignments_to_aos2/4
assignments_to_bundle/4Generate a GET /schedule response for a process as HTTP-sig bundles.
assignments_to_bundle/5*
cursor/2*Generate a cursor for an assignment.
format_opts/1*For all scheduler format operations, we do not calculate hashpaths, perform cache lookups, or await inprogress results.

Function Details

aos2_normalize_data/1 *

aos2_normalize_data(JSONStruct) -> any()

The hb_gateway_client module expects all JSON structures to at least have a data field. This function ensures that.

aos2_normalize_types/1

aos2_normalize_types(Msg) -> any()

Normalize an AOS2 formatted message to ensure that all field NAMES and types are correct. This involves converting field names to integers and specific field names to their canonical form. NOTE: This will result in a message that is not verifiable! It is, however, necessary for gaining compatibility with the AOS2-style scheduling API.

aos2_to_assignment/2

aos2_to_assignment(A, RawOpts) -> any()

Create and normalize an assignment from an AOS2-style JSON structure. NOTE: This method is destructive to the verifiability of the assignment.

aos2_to_assignments/3

aos2_to_assignments(ProcID, Body, RawOpts) -> any()

Convert an AOS2-style JSON structure to a normalized HyperBEAM assignments response.

assignment_to_aos2/2 *

assignment_to_aos2(Assignment, RawOpts) -> any()

Convert an assignment to an AOS2-compatible JSON structure.

assignments_to_aos2/4

assignments_to_aos2(ProcID, Assignments, More, RawOpts) -> any()

assignments_to_bundle/4

assignments_to_bundle(ProcID, Assignments, More, Opts) -> any()

Generate a GET /schedule response for a process as HTTP-sig bundles.

assignments_to_bundle/5 *

assignments_to_bundle(ProcID, Assignments, More, TimeInfo, RawOpts) -> any()

cursor/2 *

cursor(Assignment, RawOpts) -> any()

Generate a cursor for an assignment. This should be the slot number, at least in the case of mainnet ao.N.1 assignments. In the case of legacynet (ao.TN.1) assignments, we may want to use the assignment ID.

format_opts/1 *

format_opts(Opts) -> any()

For all scheduler format operations, we do not calculate hashpaths, perform cache lookups, or await inprogress results.