Prevalidator_bounding.Make
Build a mempool bounding module.
val empty : state
Empty state containing no operations.
type protocol_operation = Proto.operation
Type Mavryk_protocol_environment.PROTOCOL.operation
.
val add_operation :
state ->
config ->
protocol_operation Shell_operation.operation ->
(state * Mavryk_base.TzPervasives.Operation_hash.t list,
protocol_operation Shell_operation.operation option)
Stdlib.result
Try and add an operation to the state.
When the state is not full (i.e. adding the operation does not break the max_operations
nor the max_total_bytes
limits), return the updated state and an empty list.
When the state is full, return either:
compare_operations
function) and have been removed from the state to make room for the new operation, orError
when it is not possible to make room for the new operation by removing only operations that are smaller than it. In that case, the error contains op_to_overtake
, that is, the smallest operation such that if the new operation were greater than op_to_overtake
according to compare_operations
(but with an unchanged byte size), then it could be successfully added to the state. The Error
can only contain None
when no matter how the new operation compares to others, it can never be added, ie. the new operation has a bigger size than config.max_total_bytes
by itself.When the operation is already present in the state, do nothing i.e. return the unchanged state and an empty replacement list.
Precondition: the operation has been validated by the protocol in some context (otherwise calling the protocol's compare_operations
function on it may fail).
val remove_operation :
state ->
Mavryk_base.TzPervasives.Operation_hash.t ->
state
Remove the operation from the state.
Do nothing if the operation was not in the state (the returned state is then physically equal to the input state).