Commit 08e59c44 authored by Romain's avatar Romain Committed by Seb Mondet

Base: move Distributed_db_version.name into its own Name module

parent 066c041b
......@@ -40,9 +40,9 @@ let with_node f =
let node_config : Node.config =
{
genesis;
chain_name = Distributed_db_version.of_string "TEZOS_DOCGEN";
chain_name = Distributed_db_version.Name.of_string "TEZOS_DOCGEN";
sandboxed_chain_name =
Distributed_db_version.of_string "SANDBOXED_TEZOS_DOCGEN";
Distributed_db_version.Name.of_string "SANDBOXED_TEZOS_DOCGEN";
user_activated_upgrades = [];
user_activated_protocol_overrides = [];
patch_context = None;
......
......@@ -38,7 +38,7 @@ let default_p2p_port = 9732
let default_discovery_port = 10732
type chain_name = Distributed_db_version.name
type chain_name = Distributed_db_version.Name.t
type blockchain_network = {
genesis : State.Chain.genesis;
......@@ -55,7 +55,7 @@ let make_blockchain_network ~chain_name ?old_chain_name
?incompatible_chain_name ~sandboxed_chain_name
?(user_activated_upgrades = []) ?(user_activated_protocol_overrides = [])
?(default_bootstrap_peers = []) genesis =
let of_string = Distributed_db_version.of_string in
let of_string = Distributed_db_version.Name.of_string in
{
genesis;
chain_name = of_string chain_name;
......@@ -201,7 +201,7 @@ let blockchain_network_encoding : blockchain_network Data_encoding.t =
user_activated_protocol_overrides;
default_bootstrap_peers;
})
(let chain = Distributed_db_version.name_encoding in
(let chain = Distributed_db_version.Name.encoding in
obj8
(req "genesis" State.Chain.genesis_encoding)
(req "chain_name" chain)
......
......@@ -26,7 +26,7 @@
[@@@ocaml.warning "-30"]
type chain_name = Distributed_db_version.name
type chain_name = Distributed_db_version.Name.t
type blockchain_network = {
genesis : State.Chain.genesis;
......
......@@ -26,18 +26,20 @@
(** Distributed_db protocol version. *)
type name = string
module Name = struct
type t = string
let of_string x = x
let of_string x = x
let pp_name = Format.pp_print_string
let pp = Format.pp_print_string
let name_encoding =
let open Data_encoding in
def
"distributed_db_version.name"
~description:"A name for the distributed DB protocol"
string
let encoding =
let open Data_encoding in
def
"distributed_db_version.name"
~description:"A name for the distributed DB protocol"
string
end
type t = int
......@@ -53,5 +55,5 @@ let encoding =
let zero = 0
let () =
Data_encoding.Registration.register ~pp:pp_name name_encoding ;
Data_encoding.Registration.register ~pp:Name.pp Name.encoding ;
Data_encoding.Registration.register ~pp encoding
......@@ -26,13 +26,15 @@
(** [Distributed_db] protocol version. *)
type name = private string
module Name : sig
type t = private string
val of_string : string -> name
val of_string : string -> t
val pp_name : Format.formatter -> name -> unit
val pp : Format.formatter -> t -> unit
val name_encoding : name Data_encoding.t
val encoding : t Data_encoding.t
end
(** An abstract version number for the high-level [Distributed_db] messages. *)
type t = private int
......
......@@ -25,7 +25,7 @@
(*****************************************************************************)
type t = {
chain_name : Distributed_db_version.name;
chain_name : Distributed_db_version.Name.t;
distributed_db_version : Distributed_db_version.t;
p2p_version : P2p_version.t;
}
......@@ -34,7 +34,7 @@ let pp ppf {chain_name; distributed_db_version; p2p_version} =
Format.fprintf
ppf
"%a.%a (p2p: %a)"
Distributed_db_version.pp_name
Distributed_db_version.Name.pp
chain_name
Distributed_db_version.pp
distributed_db_version
......@@ -54,7 +54,7 @@ let encoding =
(fun (chain_name, distributed_db_version, p2p_version) ->
{chain_name; distributed_db_version; p2p_version})
(obj3
(req "chain_name" Distributed_db_version.name_encoding)
(req "chain_name" Distributed_db_version.Name.encoding)
(req "distributed_db_version" Distributed_db_version.encoding)
(req "p2p_version" P2p_version.encoding))
......
......@@ -25,7 +25,7 @@
(*****************************************************************************)
type t = {
chain_name : Distributed_db_version.name;
chain_name : Distributed_db_version.Name.t;
distributed_db_version : Distributed_db_version.t;
p2p_version : P2p_version.t;
}
......@@ -38,7 +38,7 @@ val encoding : t Data_encoding.t
announced on peer connection, given the [supported] versions for
the higher-level messages. *)
val announced :
chain_name:Distributed_db_version.name ->
chain_name:Distributed_db_version.Name.t ->
distributed_db_versions:Distributed_db_version.t list ->
p2p_versions:P2p_version.t list ->
t
......@@ -48,7 +48,7 @@ val announced :
by the remote peer, and [acceptables] the locally accepted
versions for the higher-level messages. *)
val select :
chain_name:Distributed_db_version.name ->
chain_name:Distributed_db_version.Name.t ->
distributed_db_versions:Distributed_db_version.t list ->
p2p_versions:P2p_version.t list ->
t ->
......
......@@ -53,7 +53,7 @@ type 'msg app_message_encoding = 'msg P2p_message.encoding =
type 'msg message_config = 'msg P2p_connect_handler.message_config = {
encoding : 'msg app_message_encoding list;
chain_name : Distributed_db_version.name;
chain_name : Distributed_db_version.Name.t;
distributed_db_versions : Distributed_db_version.t list;
}
......
......@@ -90,7 +90,7 @@ type 'conn_meta conn_meta_config = {
the type of the application level protocol *)
type 'msg message_config = {
encoding : 'msg P2p_message.encoding list; (** Encoding of the messages. *)
chain_name : Distributed_db_version.name;
chain_name : Distributed_db_version.Name.t;
(** Identifier for this P2p protocol when establishing session. *)
distributed_db_versions : Distributed_db_version.t list;
(** List of versions supported by this P2p protocol. *)
......
......@@ -29,7 +29,7 @@ end)
type 'msg message_config = {
encoding : 'msg P2p_message.encoding list;
chain_name : Distributed_db_version.name;
chain_name : Distributed_db_version.Name.t;
distributed_db_versions : Distributed_db_version.t list;
}
......@@ -382,9 +382,9 @@ let raw_authenticate t ?point_info canceler fd point =
"No common [email protected](chains: local %a - remote \
%a)@.(db_versions: local [%a] - remote %a)@.(p2p_versions: local \
[%a] - remote %a)"
Distributed_db_version.pp_name
Distributed_db_version.Name.pp
t.message_config.chain_name
Distributed_db_version.pp_name
Distributed_db_version.Name.pp
info.announced_version.chain_name
(Format.pp_print_list Distributed_db_version.pp)
t.message_config.distributed_db_versions
......
......@@ -82,7 +82,7 @@ type config = {
type 'msg message_config = {
encoding : 'msg P2p_message.encoding list;
chain_name : Distributed_db_version.name;
chain_name : Distributed_db_version.Name.t;
distributed_db_versions : Distributed_db_version.t list;
}
......
......@@ -42,7 +42,7 @@ let msg_config : message P2p_connect_handler.message_config =
unwrap = (function Ping -> Some ());
max_length = None;
} ];
chain_name = Distributed_db_version.of_string "SANDBOXED_TEZOS";
chain_name = Distributed_db_version.Name.of_string "SANDBOXED_TEZOS";
distributed_db_versions = [Distributed_db_version.zero];
}
......
......@@ -45,7 +45,7 @@ let id0 =
let version =
{
Network_version.chain_name =
Distributed_db_version.of_string "SANDBOXED_TEZOS";
Distributed_db_version.Name.of_string "SANDBOXED_TEZOS";
distributed_db_version = Distributed_db_version.zero;
p2p_version = P2p_version.zero;
}
......
......@@ -51,7 +51,7 @@ val encoding : t P2p_message.encoding list
val distributed_db_versions : Distributed_db_version.t list
val cfg : Distributed_db_version.name -> t P2p.message_config
val cfg : Distributed_db_version.Name.t -> t P2p.message_config
val pp_json : Format.formatter -> t -> unit
......
......@@ -147,8 +147,8 @@ let init_p2p chain_name p2p_params =
type config = {
genesis : State.Chain.genesis;
chain_name : Distributed_db_version.name;
sandboxed_chain_name : Distributed_db_version.name;
chain_name : Distributed_db_version.Name.t;
sandboxed_chain_name : Distributed_db_version.Name.t;
user_activated_upgrades : User_activated.upgrades;
user_activated_protocol_overrides : User_activated.protocol_overrides;
store_root : string;
......
......@@ -29,8 +29,8 @@ type t
type config = {
genesis : State.Chain.genesis;
chain_name : Distributed_db_version.name;
sandboxed_chain_name : Distributed_db_version.name;
chain_name : Distributed_db_version.Name.t;
sandboxed_chain_name : Distributed_db_version.Name.t;
user_activated_upgrades : User_activated.upgrades;
user_activated_protocol_overrides : User_activated.protocol_overrides;
store_root : string;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment