2016-09-08 21:13:10 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
2018-02-06 00:17:03 +04:00
|
|
|
(* Copyright (c) 2014 - 2018. *)
|
2016-09-08 21:13:10 +04:00
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
2017-11-13 22:06:30 +04:00
|
|
|
(** Tezos Shell - Prevalidation of pending operations (a.k.a Mempool) *)
|
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
(** The prevalidation worker is in charge of the "mempool" (a.k.a. the
|
|
|
|
set of known not-invalid-for-sure operations that are not yet
|
|
|
|
included in the blockchain).
|
|
|
|
|
|
|
|
The worker also maintains a sorted subset of the mempool that
|
|
|
|
might correspond to a valid block on top of the current head. The
|
|
|
|
"in-progress" context produced by the application of those
|
|
|
|
operations is called the (pre)validation context.
|
|
|
|
|
|
|
|
Before to include an operation into the mempool, the prevalidation
|
|
|
|
worker tries to append the operation the prevalidation context. If
|
|
|
|
the operation is (strongly) refused, it will not be added into the
|
|
|
|
mempool and then it will be ignored by the node and never
|
|
|
|
broadcasted. If the operation is only "branch_refused" or
|
|
|
|
"branch_delayed", the operation won't be appended in the
|
|
|
|
prevalidation context, but still broadcasted.
|
|
|
|
|
|
|
|
*)
|
|
|
|
|
|
|
|
type t
|
|
|
|
|
2017-11-29 16:51:06 +04:00
|
|
|
type limits = {
|
|
|
|
max_refused_operations : int ;
|
2017-11-30 21:34:22 +04:00
|
|
|
operation_timeout : float ;
|
|
|
|
worker_limits : Worker_types.limits ;
|
2017-11-29 16:51:06 +04:00
|
|
|
}
|
|
|
|
|
2018-02-16 04:26:24 +04:00
|
|
|
type error += Closed of Chain_id.t
|
2017-11-29 21:25:07 +04:00
|
|
|
|
2018-02-16 04:26:24 +04:00
|
|
|
val create: limits -> Distributed_db.chain_db -> t Lwt.t
|
2016-09-08 21:13:10 +04:00
|
|
|
val shutdown: t -> unit Lwt.t
|
2018-01-24 15:48:25 +04:00
|
|
|
val notify_operations: t -> P2p_peer.Id.t -> Mempool.t -> unit
|
2017-11-17 20:17:48 +04:00
|
|
|
val inject_operation: t -> Operation.t -> unit tzresult Lwt.t
|
2017-11-30 21:34:22 +04:00
|
|
|
val flush: t -> Block_hash.t -> unit tzresult Lwt.t
|
2016-09-08 21:13:10 +04:00
|
|
|
val timestamp: t -> Time.t
|
2017-11-27 09:13:12 +04:00
|
|
|
val operations: t -> error Preapply_result.t * Operation.t Operation_hash.Map.t
|
2018-02-17 17:39:45 +04:00
|
|
|
val context: t -> Tezos_protocol_environment_shell.validation_result tzresult Lwt.t
|
2017-11-14 02:27:19 +04:00
|
|
|
val pending: ?block:State.Block.t -> t -> Operation.t Operation_hash.Map.t Lwt.t
|
2017-11-30 21:34:22 +04:00
|
|
|
|
2018-02-16 04:26:24 +04:00
|
|
|
val running_workers: unit -> (Chain_id.t * t) list
|
2017-11-30 21:34:22 +04:00
|
|
|
val status: t -> Worker_types.worker_status
|
|
|
|
|
|
|
|
val pending_requests : t -> (Time.t * Prevalidator_worker_state.Request.view) list
|
|
|
|
val current_request : t -> (Time.t * Time.t * Prevalidator_worker_state.Request.view) option
|
|
|
|
val last_events : t -> (Lwt_log_core.level * Prevalidator_worker_state.Event.t list) list
|