package octez-l2-libs

  1. Overview
  2. Docs

This module implements a bounded FIFO queue to model the outputs. Each element of the queue is a list of outbox messages produced on this level.

type output_info = {
  1. outbox_level : int32;
    (*

    The outbox level at which the message exists.

    *)
  2. message_index : Z.t;
    (*

    The index of the message in the outbox.

    *)
}
exception Non_initialized_outbox
exception Already_initialized_outbox
exception Invalid_outbox_limit
exception Full_outbox
exception Outdated_level
exception Invalid_level
exception Invalid_id
exception Invalid_diff
type t = {
  1. outboxes : bytes Messages.t Outboxes.t;
  2. mutable last_level : int32 option;
  3. validity_period : int32;
  4. message_limit : Z.t;
    (*

    Limit of messages per outbox

    *)
}
val alloc : validity_period:int32 -> message_limit:Z.t -> last_level:int32 option -> t

alloc ~validity_period ~last_level allocates a new output_buffer. If last_level is Some level, the corresponding outbox is allocated.

val is_initialized : t -> bool

is_initialized buffer returns true if the output buffer has been initialized.

val initialize_outbox : t -> int32 -> unit

initialize_outbox buffer level initialize the output_buffer with a fresh inbox at the given level.

val move_outbox_forward : t -> unit

move_outbox_forward outboxes increments the last level of the outbox, allocates a new outbox and removes the outbox at the previous first level, according to the validity period.

val push_message : t -> bytes -> output_info Lwt.t

push_message outboxes msg push a new message in the last outbox, and returns the its level and index in the outbox.

val get_outbox : t -> int32 -> bytes Messages.Vector.t Lwt.t

get_outbox outboxes level returns the outbox for the given level.

  • raises Outdated_level

    if the outbox is outdated according to the validity period.

val get_message : t -> output_info -> bytes Lwt.t

get_message outboxes message_info finds a message in the output buffer.

  • raises Outdated_level

    if the outbox is outdated according to the validity period.

  • raises Invalid_id

    if no message with the given id exists in the outbox at this level.

val snapshot : t -> t Lwt.t

sandbox outboxes create a snapshot of the outbox. You can modify original one, snapshotted one will stay untouched.

module Internal_for_tests : sig ... end
OCaml

Innovation. Community. Security.