swh:1:snp:505c374fd75bb208ae4e9a54e64bb310bc49295e
Raw File
Tip revision: 4d22a43d056e42b7ec74657541268927c3d80ee2 authored by Joel Bjornson on 02 August 2022, 15:26:49 UTC
Benchmark: adapt benchmark
Tip revision: 4d22a43
injector_common.mli
(*****************************************************************************)
(*                                                                           *)
(* Open Source License                                                       *)
(* Copyright (c) 2022 Nomadic Labs, <contact@nomadic-labs.com>               *)
(*                                                                           *)
(* Permission is hereby granted, free of charge, to any person obtaining a   *)
(* copy of this software and associated documentation files (the "Software"),*)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense,  *)
(* and/or sell copies of the Software, and to permit persons to whom the     *)
(* Software is furnished to do so, subject to the following conditions:      *)
(*                                                                           *)
(* The above copyright notice and this permission notice shall be included   *)
(* in all copies or substantial portions of the Software.                    *)
(*                                                                           *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL   *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER       *)
(* DEALINGS IN THE SOFTWARE.                                                 *)
(*                                                                           *)
(*****************************************************************************)

open Protocol_client_context

(** The type of signers for operations injected by the injector *)
type signer = {
  alias : string;
  pkh : Tezos_crypto.Signature.public_key_hash;
  pk : Tezos_crypto.Signature.public_key;
  sk : Client_keys.sk_uri;
}

(** Type of chain reorganizations. *)
type 'block reorg = {
  old_chain : 'block list;
      (** The blocks that were in the old chain and which are not in the new one. *)
  new_chain : 'block list;
      (** The blocks that are now in the new chain. The length of [old_chain] and
      [new_chain] may be different. *)
}

(** Retrieve a signer from the client wallet. *)
val get_signer :
  #Client_context.wallet ->
  Tezos_crypto.Signature.public_key_hash ->
  signer tzresult Lwt.t

val no_reorg : 'a reorg

val reorg_encoding : 'a Data_encoding.t -> 'a reorg Data_encoding.t

type block_info := Alpha_block_services.block_info

type shell_header := Block_header.shell_header

(** [fetch_tezos_shell_header ~find_in_cache cctxt hash] returns [Some
    shell_header] given a block hash. Looks for the block using [find_in_cache]
    first, and fetches it from the L1 node otherwise. Returns [None] if no such
    block hash exists. [find_in_cache] should be from an instance of
    {!Aches_lwt.Lache.MAP_RESULT}. *)
val fetch_tezos_shell_header :
  find_in_cache:
    (Tezos_crypto.Block_hash.t ->
    (Tezos_crypto.Block_hash.t -> shell_header option Lwt.t) ->
    shell_header option Lwt.t) ->
  #full ->
  Tezos_crypto.Block_hash.t ->
  shell_header tzresult Lwt.t

(** [fetch_tezos_block ~find_in_cache cctxt hash] returns [Some block_info]
    given a block hash. Looks for the block using [find_in_cache] first, and
    fetches it from the L1 node otherwise. Returns [None] if no such block hash
    exists. [find_in_cache] should be from an instance of
    {!Aches_lwt.Lache.MAP_RESULT}. *)
val fetch_tezos_block :
  find_in_cache:
    (Tezos_crypto.Block_hash.t ->
    (Tezos_crypto.Block_hash.t -> block_info option Lwt.t) ->
    block_info option Lwt.t) ->
  #full ->
  Tezos_crypto.Block_hash.t ->
  block_info tzresult Lwt.t

(** [tezos_reorg fetch ~old_head_hash ~new_head_hash] computes the
    reorganization of L1 blocks from the chain whose head is [old_head_hash] and
    the chain whose head [new_head_hash]. *)
val tezos_reorg :
  (Tezos_crypto.Block_hash.t -> block_info tzresult Lwt.t) ->
  old_head_hash:Tezos_crypto.Block_hash.t ->
  new_head_hash:Tezos_crypto.Block_hash.t ->
  block_info reorg tzresult Lwt.t
back to top