package octez-l2-libs
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 = {
outbox_level : int32;
(*The outbox level at which the message exists.
*)message_index : Z.t;
(*The index of the message in the outbox.
*)
}
module Messages = Tezos_lazy_containers.Lazy_vector.Mutable.ZVector
module Outboxes = Tezos_lazy_containers.Lazy_map.Mutable.LwtInt32Map
type t = {
outboxes : bytes Messages.t Outboxes.t;
mutable last_level : int32 option;
validity_period : int32;
message_limit : Z.t;
(*Limit of messages per outbox
*)
}
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
.
val get_message : t -> output_info -> bytes Lwt.t
get_message outboxes message_info
finds a message in the output buffer.
sandbox outboxes
create a snapshot of the outbox. You can modify original one, snapshotted one will stay untouched.
module Internal_for_tests : sig ... end