Add docstrings in src/environment/v1/

This commit is contained in:
Pietro Abate 2017-11-14 00:42:58 +01:00 committed by Grégoire
parent 1429a6c8e6
commit 3e1c4008c3
3 changed files with 39 additions and 17 deletions

View File

@ -7,6 +7,10 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
(** Tezos Protocol Environment - Basic data structures *)
(** Generic interface for a datatype with comparison, pretty-printer
and serialization functions. *)
module type DATA = sig module type DATA = sig
type t type t
@ -31,8 +35,8 @@ module type DATA = sig
end end
module Fitness : DATA with type t = MBytes.t list (** Generic interface for a datatype with comparison, pretty-printer,
serialization functions and a hashing function. *)
module type HASHABLE_DATA = sig module type HASHABLE_DATA = sig
include DATA include DATA
@ -43,11 +47,18 @@ module type HASHABLE_DATA = sig
end end
(** The fitness of a block is defined as a list of bytes,
compared in a lexicographical order (longer list are greater). *)
module Fitness : DATA with type t = MBytes.t list
(** Tezos operations. *)
module Operation : sig module Operation : sig
type shell_header = { type shell_header = {
net_id: Net_id.t ; net_id: Net_id.t ;
branch: Block_hash.t ; branch: Block_hash.t ;
(** The operation is only valid in a branch containing the
block [branch]. *)
} }
val shell_header_encoding: shell_header Data_encoding.t val shell_header_encoding: shell_header Data_encoding.t
@ -66,10 +77,14 @@ module Block_header : sig
type shell_header = { type shell_header = {
net_id: Net_id.t ; net_id: Net_id.t ;
level: Int32.t ; level: Int32.t ;
proto_level: int ; (* uint8 *) (** The number of preceding block in this chain, i.e. the genesis
has level 0. *)
proto_level: int ;
(** The number of preceding protocol change in the chain (modulo 256),
i.e the genesis has proto_level 0. *)
predecessor: Block_hash.t ; predecessor: Block_hash.t ;
timestamp: Time.t ; timestamp: Time.t ;
validation_passes: int ; (* uint8 *) validation_passes: int ;
operations_hash: Operation_list_list_hash.t ; operations_hash: Operation_list_list_hash.t ;
fitness: MBytes.t list ; fitness: MBytes.t list ;
} }

View File

@ -7,7 +7,7 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
(** Tezos Protocol Environment - Protocol Implementation Updater *) (** Tezos Protocol Environment - Protocol updater. *)
type validation_result = { type validation_result = {
context: Context.t ; context: Context.t ;
@ -31,13 +31,13 @@ module type PROTOCOL = sig
(** The version specific type of operations. *) (** The version specific type of operations. *)
type operation type operation
(** The maximum size of operations in bytes *) (** The maximum size of operations in bytes. *)
val max_operation_data_length: int val max_operation_data_length: int
(** The maximum size of block headers in bytes *) (** The maximum size of block headers in bytes. *)
val max_block_length: int val max_block_length: int
(** The maximum *) (** The maximum number of operations allowed in one block. *)
val max_number_of_operations: int val max_number_of_operations: int
(** The parsing / preliminary validation function for (** The parsing / preliminary validation function for
@ -75,11 +75,10 @@ module type PROTOCOL = sig
(** The first step in a block validation sequence. Initializes a (** The first step in a block validation sequence. Initializes a
validation context for validating a block. Takes as argument the validation context for validating a block. Takes as argument the
{!Block_header.t} to initialize the context for this block, patching {!Block_header.t} to initialize the context for this block. The
the context resulting of the application of the predecessor function {!precheck_block} may not have been called before
block passed as parameter. The function {!precheck_block} may [begin_application], so all the check performed by the former
not have been called before [begin_application], so all the must be repeated in the latter. *)
check performed by the former must be repeated in the latter. *)
val begin_application: val begin_application:
predecessor_context: Context.t -> predecessor_context: Context.t ->
predecessor_timestamp: Time.t -> predecessor_timestamp: Time.t ->
@ -88,10 +87,13 @@ module type PROTOCOL = sig
validation_state tzresult Lwt.t validation_state tzresult Lwt.t
(** Initializes a validation context for constructing a new block (** Initializes a validation context for constructing a new block
(as opposed to validating an existing block). Since there is no (as opposed to validating an existing block). When the
{!Block_header.t} header available, the parts that it provides are [proto_header] argument is not specified, the function should
passed as arguments (predecessor block hash, context resulting produce the exact same effect on the context than would produce
of the application of the predecessor block, and timestamp). *) the validation of a block containing an "equivalent" (but
complete) header. For instance, if the block header usually
includes a signature, the header provided to
{!begin_construction} could includes a faked signature. *)
val begin_construction: val begin_construction:
predecessor_context: Context.t -> predecessor_context: Context.t ->
predecessor_timestamp: Time.t -> predecessor_timestamp: Time.t ->
@ -116,6 +118,9 @@ module type PROTOCOL = sig
(** The list of remote procedures exported by this implementation *) (** The list of remote procedures exported by this implementation *)
val rpc_services: rpc_context RPC.directory val rpc_services: rpc_context RPC.directory
(** An ad-hoc context patcher. It used only for debugging protocol
while running in the "sandbox" mode. This function is never used
in production. *)
val configure_sandbox: val configure_sandbox:
Context.t -> Data_encoding.json option -> Context.t tzresult Lwt.t Context.t -> Data_encoding.json option -> Context.t tzresult Lwt.t

View File

@ -7,6 +7,8 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
(** Tezos Protocol Environment - Arbitrary precision arithmetic. *)
type t type t
val zero: t val zero: t
val one: t val one: t