2017-04-19 23:46:10 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
2018-02-06 00:17:03 +04:00
|
|
|
(* Copyright (c) 2014 - 2018. *)
|
2017-04-19 23:46:10 +04:00
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
2017-11-13 17:33:39 +04:00
|
|
|
(** Tezos Shell Module - Manging the current head. *)
|
2017-04-19 23:46:10 +04:00
|
|
|
|
2018-02-16 04:26:24 +04:00
|
|
|
(** The genesis block of the chain. On a test chain,
|
2017-04-19 23:46:10 +04:00
|
|
|
the test protocol has been promoted as "main" protocol. *)
|
2018-02-16 04:26:24 +04:00
|
|
|
val genesis: State.Chain.t -> State.Block.t Lwt.t
|
2017-04-19 23:46:10 +04:00
|
|
|
|
2018-02-16 04:26:24 +04:00
|
|
|
(** The current head of the chain. *)
|
|
|
|
val head: State.Chain.t -> State.Block.t Lwt.t
|
2018-03-21 18:38:41 +04:00
|
|
|
val locator: State.Chain.t -> Block_locator.seed -> Block_locator.t Lwt.t
|
2017-04-19 23:46:10 +04:00
|
|
|
|
2017-11-14 04:29:19 +04:00
|
|
|
(** All the available chain data. *)
|
|
|
|
type data = {
|
2018-02-16 04:26:24 +04:00
|
|
|
current_head: State.Block.t ;
|
2017-11-30 21:34:22 +04:00
|
|
|
current_mempool: Mempool.t ;
|
2017-11-14 04:29:19 +04:00
|
|
|
live_blocks: Block_hash.Set.t ;
|
|
|
|
live_operations: Operation_hash.Set.t ;
|
|
|
|
}
|
|
|
|
|
|
|
|
(** Reading atomically all the chain data. *)
|
2018-02-16 04:26:24 +04:00
|
|
|
val data: State.Chain.t -> data Lwt.t
|
2017-11-14 04:29:19 +04:00
|
|
|
|
2017-11-13 17:33:39 +04:00
|
|
|
(** The current head and all the known (valid) alternate heads. *)
|
2018-02-16 04:26:24 +04:00
|
|
|
val known_heads: State.Chain.t -> State.Block.t list Lwt.t
|
2017-04-19 23:46:10 +04:00
|
|
|
|
2018-02-16 04:26:24 +04:00
|
|
|
(** Test whether a block belongs to the current mainchain. *)
|
|
|
|
val mem: State.Chain.t -> Block_hash.t -> bool Lwt.t
|
2017-09-29 20:43:13 +04:00
|
|
|
|
2018-02-16 04:26:24 +04:00
|
|
|
(** Record a block as the current head of the chain.
|
2017-11-11 06:34:12 +04:00
|
|
|
It returns the previous head. *)
|
2018-02-16 04:26:24 +04:00
|
|
|
val set_head: State.Chain.t -> State.Block.t -> State.Block.t Lwt.t
|
2017-04-19 23:46:10 +04:00
|
|
|
|
2018-02-16 04:26:24 +04:00
|
|
|
(** Atomically change the current head of the chain.
|
2017-04-19 23:46:10 +04:00
|
|
|
This returns [true] whenever the change succeeded, or [false]
|
|
|
|
when the current head os not equal to the [old] argument. *)
|
2017-11-14 04:24:25 +04:00
|
|
|
val test_and_set_head:
|
2018-02-16 04:26:24 +04:00
|
|
|
State.Chain.t -> old:State.Block.t -> State.Block.t -> bool Lwt.t
|
2017-11-13 17:33:39 +04:00
|
|
|
|
2017-12-14 21:46:55 +04:00
|
|
|
(** Restores the data about the current head at startup
|
|
|
|
(recomputes the sets of live blocks and operations). *)
|
2018-02-16 04:26:24 +04:00
|
|
|
val init_head: State.Chain.t -> unit Lwt.t
|