Proto_sigs: split the deprecated module Tezos_data
This commit is contained in:
parent
db57afa4d1
commit
04465e3ac6
@ -56,21 +56,17 @@ module Make(Param : sig val name: string end)() = struct
|
||||
module Make_Blake2B = Blake2B.Make
|
||||
end
|
||||
module Blake2B = Blake2B
|
||||
module Tezos_data = struct
|
||||
module type DATA = S.T
|
||||
module type HASHABLE_DATA = S.HASHABLE
|
||||
module Fitness = Fitness
|
||||
module Operation = Operation
|
||||
module Block_header = Block_header
|
||||
module Protocol = Protocol
|
||||
end
|
||||
module S = S
|
||||
module Fitness = Fitness
|
||||
module Operation = Operation
|
||||
module Block_header = Block_header
|
||||
module Protocol = Protocol
|
||||
module RPC_arg = RPC_arg
|
||||
module RPC_path = RPC_path
|
||||
module RPC_query = RPC_query
|
||||
module RPC_service = RPC_service
|
||||
module RPC_answer = RPC_answer
|
||||
module RPC_directory = RPC_directory
|
||||
module Fitness = Fitness
|
||||
module Error_monad = struct
|
||||
type error_category = [ `Branch | `Temporary | `Permanent ]
|
||||
include Error_monad.Make()
|
||||
|
@ -48,8 +48,7 @@ let () = Format.kasprintf Jbuild_plugin.V1.send {|
|
||||
-warn-error -a+8
|
||||
-open Tezos_embedded_protocol_environment_%s__Environment
|
||||
-open Error_monad
|
||||
-open Hash
|
||||
-open Tezos_data))
|
||||
-open Hash))
|
||||
(modules (:standard \ Environment Registerer))))
|
||||
|
||||
(library
|
||||
|
@ -45,7 +45,6 @@ let opened_modules = [
|
||||
"Error_monad" ;
|
||||
"Hash" ;
|
||||
"Logging" ;
|
||||
"Tezos_data" ;
|
||||
]
|
||||
|
||||
let dump oc files =
|
||||
|
@ -45,8 +45,12 @@
|
||||
v1/ed25519.mli
|
||||
|
||||
;; Tezos specifics
|
||||
v1/s.mli
|
||||
v1/micheline.mli
|
||||
v1/tezos_data.mli
|
||||
v1/block_header.mli
|
||||
v1/fitness.mli
|
||||
v1/operation.mli
|
||||
v1/protocol.mli
|
||||
v1/context.mli
|
||||
v1/updater.mli
|
||||
|
||||
|
@ -25,7 +25,6 @@ let opened_modules = [
|
||||
"Pervasives" ;
|
||||
"Error_monad" ;
|
||||
"Hash" ;
|
||||
"Tezos_data" ;
|
||||
]
|
||||
|
||||
let include_mli oc file =
|
||||
|
33
src/lib_protocol_environment_sigs/v1/block_header.mli
Normal file
33
src/lib_protocol_environment_sigs/v1/block_header.mli
Normal file
@ -0,0 +1,33 @@
|
||||
(**************************************************************************)
|
||||
(* *)
|
||||
(* Copyright (c) 2014 - 2017. *)
|
||||
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
||||
(* *)
|
||||
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
||||
(* *)
|
||||
(**************************************************************************)
|
||||
|
||||
type shell_header = {
|
||||
level: Int32.t ;
|
||||
(** 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 ;
|
||||
timestamp: Time.t ;
|
||||
validation_passes: int ;
|
||||
operations_hash: Operation_list_list_hash.t ;
|
||||
fitness: MBytes.t list ;
|
||||
context: Context_hash.t ;
|
||||
}
|
||||
|
||||
val shell_header_encoding: shell_header Data_encoding.t
|
||||
|
||||
type t = {
|
||||
shell: shell_header ;
|
||||
proto: MBytes.t ;
|
||||
}
|
||||
|
||||
include S.HASHABLE with type t := t
|
||||
and type hash := Block_hash.t
|
@ -7,10 +7,6 @@
|
||||
(* *)
|
||||
(**************************************************************************)
|
||||
|
||||
type fitness = MBytes.t list
|
||||
|
||||
val compare: fitness -> fitness -> int
|
||||
val pp: Format.formatter -> fitness -> unit
|
||||
val to_string: fitness -> string
|
||||
|
||||
val encoding: fitness Data_encoding.t
|
||||
(** The fitness of a block is defined as a list of bytes,
|
||||
compared in a lexicographical order (longer list are greater). *)
|
||||
include S.T with type t = MBytes.t list
|
||||
|
25
src/lib_protocol_environment_sigs/v1/operation.mli
Normal file
25
src/lib_protocol_environment_sigs/v1/operation.mli
Normal file
@ -0,0 +1,25 @@
|
||||
(**************************************************************************)
|
||||
(* *)
|
||||
(* Copyright (c) 2014 - 2017. *)
|
||||
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
||||
(* *)
|
||||
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
||||
(* *)
|
||||
(**************************************************************************)
|
||||
|
||||
(** Tezos operations. *)
|
||||
|
||||
type shell_header = {
|
||||
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
|
||||
|
||||
type t = {
|
||||
shell: shell_header ;
|
||||
proto: MBytes.t ;
|
||||
}
|
||||
|
||||
include S.HASHABLE with type t := t
|
||||
and type hash := Operation_hash.t
|
31
src/lib_protocol_environment_sigs/v1/protocol.mli
Normal file
31
src/lib_protocol_environment_sigs/v1/protocol.mli
Normal file
@ -0,0 +1,31 @@
|
||||
(**************************************************************************)
|
||||
(* *)
|
||||
(* Copyright (c) 2014 - 2017. *)
|
||||
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
||||
(* *)
|
||||
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
||||
(* *)
|
||||
(**************************************************************************)
|
||||
|
||||
type t = {
|
||||
expected_env: env_version ;
|
||||
components: component list ;
|
||||
}
|
||||
|
||||
(** An OCaml source component of a protocol implementation. *)
|
||||
and component = {
|
||||
(* The OCaml module name. *)
|
||||
name : string ;
|
||||
(* The OCaml interface source code *)
|
||||
interface : string option ;
|
||||
(* The OCaml source code *)
|
||||
implementation : string ;
|
||||
}
|
||||
|
||||
and env_version = V1
|
||||
|
||||
val component_encoding: component Data_encoding.t
|
||||
val env_version_encoding: env_version Data_encoding.t
|
||||
|
||||
include S.HASHABLE with type t := t
|
||||
and type hash := Protocol_hash.t
|
46
src/lib_protocol_environment_sigs/v1/s.mli
Normal file
46
src/lib_protocol_environment_sigs/v1/s.mli
Normal file
@ -0,0 +1,46 @@
|
||||
(**************************************************************************)
|
||||
(* *)
|
||||
(* Copyright (c) 2014 - 2017. *)
|
||||
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
||||
(* *)
|
||||
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
||||
(* *)
|
||||
(**************************************************************************)
|
||||
|
||||
(** Generic interface for a datatype with comparison, pretty-printer
|
||||
and serialization functions. *)
|
||||
module type T = sig
|
||||
|
||||
type t
|
||||
|
||||
val compare: t -> t -> int
|
||||
val equal: t -> t -> bool
|
||||
|
||||
val (=): t -> t -> bool
|
||||
val (<>): t -> t -> bool
|
||||
val (<): t -> t -> bool
|
||||
val (<=): t -> t -> bool
|
||||
val (>=): t -> t -> bool
|
||||
val (>): t -> t -> bool
|
||||
val min: t -> t -> t
|
||||
val max: t -> t -> t
|
||||
|
||||
val pp: Format.formatter -> t -> unit
|
||||
|
||||
val encoding: t Data_encoding.t
|
||||
val to_bytes: t -> MBytes.t
|
||||
val of_bytes: MBytes.t -> t option
|
||||
|
||||
end
|
||||
|
||||
(** Generic interface for a datatype with comparison, pretty-printer,
|
||||
serialization functions and a hashing function. *)
|
||||
module type HASHABLE = sig
|
||||
|
||||
include T
|
||||
|
||||
type hash
|
||||
val hash: t -> hash
|
||||
val hash_raw: MBytes.t -> hash
|
||||
|
||||
end
|
@ -1,128 +1,5 @@
|
||||
(**************************************************************************)
|
||||
(* *)
|
||||
(* Copyright (c) 2014 - 2017. *)
|
||||
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
||||
(* *)
|
||||
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
||||
(* *)
|
||||
(**************************************************************************)
|
||||
|
||||
(** Tezos Protocol Environment - Basic data structures *)
|
||||
|
||||
(** Generic interface for a datatype with comparison, pretty-printer
|
||||
and serialization functions. *)
|
||||
module type DATA = sig
|
||||
|
||||
type t
|
||||
|
||||
val compare: t -> t -> int
|
||||
val equal: t -> t -> bool
|
||||
|
||||
val (=): t -> t -> bool
|
||||
val (<>): t -> t -> bool
|
||||
val (<): t -> t -> bool
|
||||
val (<=): t -> t -> bool
|
||||
val (>=): t -> t -> bool
|
||||
val (>): t -> t -> bool
|
||||
val min: t -> t -> t
|
||||
val max: t -> t -> t
|
||||
|
||||
val pp: Format.formatter -> t -> unit
|
||||
|
||||
val encoding: t Data_encoding.t
|
||||
val to_bytes: t -> MBytes.t
|
||||
val of_bytes: MBytes.t -> t option
|
||||
|
||||
end
|
||||
|
||||
(** Generic interface for a datatype with comparison, pretty-printer,
|
||||
serialization functions and a hashing function. *)
|
||||
module type HASHABLE_DATA = sig
|
||||
|
||||
include DATA
|
||||
|
||||
type hash
|
||||
val hash: t -> hash
|
||||
val hash_raw: MBytes.t -> hash
|
||||
|
||||
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
|
||||
|
||||
type shell_header = {
|
||||
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
|
||||
|
||||
type t = {
|
||||
shell: shell_header ;
|
||||
proto: MBytes.t ;
|
||||
}
|
||||
|
||||
include HASHABLE_DATA with type t := t
|
||||
and type hash := Operation_hash.t
|
||||
|
||||
end
|
||||
|
||||
module Block_header : sig
|
||||
|
||||
type shell_header = {
|
||||
level: Int32.t ;
|
||||
(** 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 ;
|
||||
timestamp: Time.t ;
|
||||
validation_passes: int ;
|
||||
operations_hash: Operation_list_list_hash.t ;
|
||||
fitness: MBytes.t list ;
|
||||
context: Context_hash.t ;
|
||||
}
|
||||
|
||||
val shell_header_encoding: shell_header Data_encoding.t
|
||||
|
||||
type t = {
|
||||
shell: shell_header ;
|
||||
proto: MBytes.t ;
|
||||
}
|
||||
|
||||
include HASHABLE_DATA with type t := t
|
||||
and type hash := Block_hash.t
|
||||
|
||||
end
|
||||
|
||||
module Protocol : sig
|
||||
|
||||
type t = {
|
||||
expected_env: env_version ;
|
||||
components: component list ;
|
||||
}
|
||||
|
||||
(** An OCaml source component of a protocol implementation. *)
|
||||
and component = {
|
||||
(* The OCaml module name. *)
|
||||
name : string ;
|
||||
(* The OCaml interface source code *)
|
||||
interface : string option ;
|
||||
(* The OCaml source code *)
|
||||
implementation : string ;
|
||||
}
|
||||
|
||||
and env_version = V1
|
||||
|
||||
val component_encoding: component Data_encoding.t
|
||||
val env_version_encoding: env_version Data_encoding.t
|
||||
|
||||
include HASHABLE_DATA with type t := t
|
||||
and type hash := Protocol_hash.t
|
||||
|
||||
end
|
||||
|
@ -105,10 +105,10 @@ module Node_protocol_environment_sigs = struct
|
||||
and type Context.t = Context.t
|
||||
and type Time.t = Time.t
|
||||
and type MBytes.t = MBytes.t
|
||||
and type Tezos_data.Operation.shell_header = Operation.shell_header
|
||||
and type Tezos_data.Operation.t = Operation.t
|
||||
and type Tezos_data.Block_header.shell_header = Block_header.shell_header
|
||||
and type Tezos_data.Block_header.t = Block_header.t
|
||||
and type Operation.shell_header = Operation.shell_header
|
||||
and type Operation.t = Operation.t
|
||||
and type Block_header.shell_header = Block_header.shell_header
|
||||
and type Block_header.t = Block_header.t
|
||||
and type 'a RPC_directory.t = 'a RPC_directory.t
|
||||
and type Updater.validation_result = validation_result
|
||||
and type Updater.rpc_context = rpc_context
|
||||
|
@ -95,10 +95,10 @@ module Node_protocol_environment_sigs : sig
|
||||
and type Context.t = Context.t
|
||||
and type Time.t = Time.t
|
||||
and type MBytes.t = MBytes.t
|
||||
and type Tezos_data.Operation.shell_header = Operation.shell_header
|
||||
and type Tezos_data.Operation.t = Operation.t
|
||||
and type Tezos_data.Block_header.shell_header = Block_header.shell_header
|
||||
and type Tezos_data.Block_header.t = Block_header.t
|
||||
and type Operation.shell_header = Operation.shell_header
|
||||
and type Operation.t = Operation.t
|
||||
and type Block_header.shell_header = Block_header.shell_header
|
||||
and type Block_header.t = Block_header.t
|
||||
and type 'a RPC_directory.t = 'a RPC_directory.t
|
||||
and type Updater.validation_result = validation_result
|
||||
and type Updater.rpc_context = rpc_context
|
||||
|
@ -26,11 +26,11 @@ and proto_header = {
|
||||
|
||||
type block_header = t
|
||||
|
||||
type raw = Tezos_data.Block_header.t
|
||||
type shell_header = Tezos_data.Block_header.shell_header
|
||||
type raw = Block_header.t
|
||||
type shell_header = Block_header.shell_header
|
||||
|
||||
let raw_encoding = Tezos_data.Block_header.encoding
|
||||
let shell_header_encoding = Tezos_data.Block_header.shell_header_encoding
|
||||
let raw_encoding = Block_header.encoding
|
||||
let shell_header_encoding = Block_header.shell_header_encoding
|
||||
|
||||
let proto_header_encoding =
|
||||
let open Data_encoding in
|
||||
|
@ -24,8 +24,8 @@ and proto_header = {
|
||||
|
||||
type block_header = t
|
||||
|
||||
type raw = Tezos_data.Block_header.t
|
||||
type shell_header = Tezos_data.Block_header.shell_header
|
||||
type raw = Block_header.t
|
||||
type shell_header = Block_header.shell_header
|
||||
|
||||
val encoding: block_header Data_encoding.encoding
|
||||
val raw_encoding: raw Data_encoding.t
|
||||
|
@ -413,3 +413,5 @@ let parse_proto bytes =
|
||||
| None -> fail Cannot_parse_operation
|
||||
|
||||
include Encoding
|
||||
|
||||
let hash_raw = Operation.hash
|
||||
|
@ -92,6 +92,8 @@ type error += Cannot_parse_operation (* `Branch *)
|
||||
|
||||
val encoding: operation Data_encoding.t
|
||||
|
||||
val hash_raw: raw -> Operation_hash.t
|
||||
|
||||
val parse:
|
||||
Operation_hash.t -> Operation.t -> operation tzresult
|
||||
|
||||
|
@ -533,7 +533,7 @@ let parse_operations ctxt () (operations, check) =
|
||||
map_s begin fun raw ->
|
||||
begin
|
||||
Lwt.return
|
||||
(Operation.parse (Tezos_data.Operation.hash raw) raw) >>=? fun op ->
|
||||
(Operation.parse (Operation.hash_raw raw) raw) >>=? fun op ->
|
||||
begin match check with
|
||||
| Some true -> check_signature ctxt op.signature op.shell op.contents
|
||||
| Some false | None -> return ()
|
||||
|
@ -605,6 +605,8 @@ module Operation : sig
|
||||
type t = operation
|
||||
val encoding: operation Data_encoding.t
|
||||
|
||||
val hash_raw: raw -> Operation_hash.t
|
||||
|
||||
type error += Cannot_parse_operation (* `Branch *)
|
||||
val parse: Operation_hash.t -> Operation.t -> operation tzresult
|
||||
|
||||
@ -641,8 +643,8 @@ module Block_header : sig
|
||||
|
||||
type block_header = t
|
||||
|
||||
type raw = Tezos_data.Block_header.t
|
||||
type shell_header = Tezos_data.Block_header.shell_header
|
||||
type raw = Block_header.t
|
||||
type shell_header = Block_header.shell_header
|
||||
|
||||
val hash: block_header -> Block_hash.t
|
||||
val hash_raw: raw -> Block_hash.t
|
||||
|
Loading…
Reference in New Issue
Block a user