package octez-libs

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type Tezos_base.TzPervasives.error +=
  1. | No_identity_file of string
type Tezos_base.TzPervasives.error +=
  1. | Insufficient_proof_of_work of {
    1. expected : float;
    }
type Tezos_base.TzPervasives.error +=
  1. | Existent_identity_file of string

read ?expected_pow filename reads an P2p_identity.t from disk at location filename. If expected_pow is set, the function also checks that the read identity has the expected PoW.

The function fails with:

  • No_identity_file if the given file is not found;
  • Identity_mismatch if the given identity is ill-formed (the id is not the hash of the public key);
  • Identity_keys_mismatch if the the public and secret keys do not match;
  • Insufficient_proof_of_work if the read identity doesn't have the expected PoW.
val write : check_data_dir: (data_dir:string -> unit Tezos_base.TzPervasives.tzresult Lwt.t) -> string -> Tezos_base.TzPervasives.P2p_identity.t -> unit Tezos_base.TzPervasives.tzresult Lwt.t

write ~check_data_dir filename identity writes identity into file filename. The function fails with Existent_identity_file if the file already exists.

See init for check_data_dir.

val generate : check_data_dir: (data_dir:string -> unit Tezos_base.TzPervasives.tzresult Lwt.t) -> string -> float -> Tezos_base.TzPervasives.P2p_identity.t Tezos_base.TzPervasives.tzresult Lwt.t

generate ~check_data_dir filename expected_pow generates a fresh identity with the given expected_pow and saves it into filename. The function fails with Existent_identity_file if filename already exists.

val init : check_data_dir: (data_dir:string -> unit Tezos_base.TzPervasives.tzresult Lwt.t) -> identity_file:string -> expected_pow:float -> Tezos_base.TzPervasives.P2p_identity.t Tezos_base.TzPervasives.tzresult Lwt.t

init ~check_data_dir ~identity_file ~expected_pow returns the P2p_identity.t read from identity_file, if any. Otherwise, it generates a fresh one with the given expected_pow, saves it into identity_file and returns it. In this latter case, the function check_data_dir can be used to enforce invariants on the "data dir" (the directory containing the identity file).

OCaml

Innovation. Community. Security.