Page
Library
Module
Module type
Parameter
Class
Class type
Source
Octez_crawler.Layer_1SourceThis module allow to follow the layer 1 chain by subscribing to the head monitoring RPC offered by the Tezos node, reconnecting, etc.
The type of layer 1 followers.
val start :
name:string ->
reconnection_delay:float ->
Tezos_client_base.Client_context.full ->
t Tezos_base.TzPervasives.tzresult Lwt.tstart ~name ~reconnection_delay cctxt connects to a Tezos node and starts monitoring new heads. One can iterate on the heads by calling iter_heads on its result. reconnection_delay gives an initial delay for the reconnection which is used in an exponential backoff. The name is used to differentiate events.
val iter_heads :
t ->
((Tezos_base.TzPervasives.Block_hash.t * Tezos_base.Block_header.t) ->
unit Tezos_base.TzPervasives.tzresult Lwt.t) ->
unit Tezos_base.TzPervasives.tzresult Lwt.titer_heads t f calls f on all new heads appearing in the layer 1 chain. In case of a disconnection with the layer 1 node, it reconnects automatically. If f returns an error (other than a disconnection), iter_heads terminates and returns the error.
val get_predecessor_opt :
t ->
(Tezos_base.TzPervasives.Block_hash.t * int32) ->
(Tezos_base.TzPervasives.Block_hash.t * int32) option
Tezos_base.TzPervasives.tzresult
Lwt.tget_predecessor_opt state head returns the predecessor of block head, when head is not the genesis block.
val get_predecessor :
t ->
(Tezos_base.TzPervasives.Block_hash.t * int32) ->
(Tezos_base.TzPervasives.Block_hash.t * int32)
Tezos_base.TzPervasives.tzresult
Lwt.tget_predecessor state head returns the predecessor block of head.
val nth_predecessor :
get_predecessor:('a -> 'a Tezos_base.TzPervasives.tzresult Lwt.t) ->
int ->
'a ->
('a * 'a Tezos_base.TzPervasives.trace) Tezos_base.TzPervasives.tzresult
Lwt.tnth_predecessor ~get_predecessor n head returns block, history where block is the nth predecessor of head and history is the list of blocks between block (excluded) and head (included) on the chain. It uses the function get_predecessor to retrieve the predecessor of one block.
val get_tezos_reorg_for_new_head :
t ->
?get_old_predecessor:
((Tezos_base.TzPervasives.Block_hash.t * int32) ->
(Tezos_base.TzPervasives.Block_hash.t * int32)
Tezos_base.TzPervasives.tzresult
Lwt.t) ->
[ `Head of Tezos_base.TzPervasives.Block_hash.t * int32 | `Level of int32 ] ->
(Tezos_base.TzPervasives.Block_hash.t * int32) ->
(Tezos_base.TzPervasives.Block_hash.t * int32) Reorg.t
Tezos_base.TzPervasives.tzresult
Lwt.tget_tezos_reorg_for_new_head l1_ctxt ?get_old_predecessor old_head new_head returns the reorganization of L1 blocks between old_head and new_head. If old_head is `Level l, then it returns the reorganization between new_head and level l on the same chain. get_old_predecessor can be provided to use a different function (than by default get_predecessor) to retrieve the predecessors of the old head. This is necessary when the old head is not in the L1 chain anymore and forgotten by the L1 node.