Mavryk_raw_protocol_001_PtAtLas.Ticket_storage
type Mavryk_protocol_environment_001_PtAtLas.Error_monad.error +=
| Negative_ticket_balance of {
key : Ticket_hash_repr.t;
balance : Mavryk_protocol_environment_001_PtAtLas.Z.t;
}
| Used_storage_space_underflow
val get_balance :
Raw_context.t ->
Ticket_hash_repr.t ->
(Mavryk_protocol_environment_001_PtAtLas.Z.t option * Raw_context.t)
Mavryk_protocol_environment_001_PtAtLas.Error_monad.tzresult
Mavryk_protocol_environment_001_PtAtLas.Lwt.t
get_balance ctxt key
receives the ticket balance for the given key
in the context ctxt
. The key
represents a ticket content and a ticket creator pair. In case there exists no value for the given key
, None
is returned.
val adjust_balance :
Raw_context.t ->
Ticket_hash_repr.t ->
delta:Mavryk_protocol_environment_001_PtAtLas.Z.t ->
(Mavryk_protocol_environment_001_PtAtLas.Z.t * Raw_context.t)
Mavryk_protocol_environment_001_PtAtLas.Error_monad.tzresult
Mavryk_protocol_environment_001_PtAtLas.Lwt.t
adjust_balance ctxt key ~delta
adjusts the balance of the given key (representing a ticket content, creator and owner pair) and delta
. The value of delta
can be positive as well as negative. If there is no pre-exising balance for the given ticket type and owner, it is assumed to be 0 and the new balance is delta
. The function also returns the difference between the old and the new size of the storage. Note that the difference may be negative. For example, because when setting the balance to zero, an entry is removed.
The function fails with a Negative_ticket_balance
error in case the resulting balance is negative.
val adjust_storage_space :
Raw_context.t ->
storage_diff:Mavryk_protocol_environment_001_PtAtLas.Z.t ->
(Mavryk_protocol_environment_001_PtAtLas.Z.t * Raw_context.t)
Mavryk_protocol_environment_001_PtAtLas.Error_monad.tzresult
Mavryk_protocol_environment_001_PtAtLas.Lwt.t
adjust_storage_space ctxt ~storage_diff
updates the used storage space for the ticket-table according to storage_diff
. The additional positive amount of unpaid storage is returned. If no unpaid storage is consumed, this amount is 0.
Note that when storage space for the ticket table is released we may later use that space for free. For this reason, the amount returned may be less than the given (positive) storage_diff
.
module Internal_for_tests : sig ... end