From 57109435d539adb75f56e18b77c67220c31e042d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Fri, 29 Sep 2017 18:43:13 +0200 Subject: [PATCH] Node/Validator: minor renaming --- src/node/shell/node.ml | 8 ++++---- src/node/shell/validator.ml | 14 +++++++------- src/node/shell/validator.mli | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/node/shell/node.ml b/src/node/shell/node.ml index 9aee1554c..85fce9f43 100644 --- a/src/node/shell/node.ml +++ b/src/node/shell/node.ml @@ -101,15 +101,15 @@ let may_create_net state genesis = let create { genesis ; store_root ; context_root ; patch_context ; p2p = net_params ; - test_network_max_tll = max_ttl } = + test_network_max_tll = max_child_ttl } = init_p2p net_params >>=? fun p2p -> State.read ~store_root ~context_root ?patch_context () >>=? fun state -> let distributed_db = Distributed_db.create state p2p in - let validator = - Validator.create ?max_ttl state distributed_db in + let validator = Validator.create state distributed_db in may_create_net state genesis >>= fun mainnet_net -> - Validator.activate validator mainnet_net >>= fun mainnet_validator -> + Validator.activate validator + ?max_child_ttl mainnet_net >>= fun mainnet_validator -> let mainnet_db = Validator.net_db mainnet_validator in let shutdown () = State.close state >>= fun () -> diff --git a/src/node/shell/validator.ml b/src/node/shell/validator.ml index bec9e8d95..3e33febb7 100644 --- a/src/node/shell/validator.ml +++ b/src/node/shell/validator.ml @@ -10,7 +10,7 @@ open Logging.Node.Validator type t = { - activate: ?parent:net_validator -> State.Net.t -> net_validator Lwt.t ; + activate: ?parent:net_validator -> ?max_child_ttl:int -> State.Net.t -> net_validator Lwt.t ; get: Net_id.t -> net_validator tzresult Lwt.t ; get_exn: Net_id.t -> net_validator Lwt.t ; deactivate: net_validator -> unit Lwt.t ; @@ -48,7 +48,7 @@ and net_validator = { let net_state { net } = net let net_db { net_db } = net_db -let activate w net = w.activate net +let activate w ?max_child_ttl net = w.activate ?max_child_ttl net let deactivate net_validator = net_validator.worker.deactivate net_validator let get w = w.get let get_exn w = w.get_exn @@ -605,7 +605,7 @@ module Context_db = struct end -let rec create_validator ?max_ttl ?parent worker state db net = +let rec create_validator ?parent worker ?max_child_ttl state db net = let queue = Lwt_pipe.create () in let current_ops = ref (fun () -> []) in @@ -744,7 +744,7 @@ let rec create_validator ?max_ttl ?parent worker state db net = | Some child -> Block_hash.equal (State.Net.genesis child.net).block genesis in begin - match max_ttl with + match max_child_ttl with | None -> Lwt.return expiration | Some ttl -> Distributed_db.Block_header.fetch net_db genesis () >>= fun genesis -> @@ -787,7 +787,7 @@ let rec create_validator ?max_ttl ?parent worker state db net = type error += Unknown_network of Net_id.t -let create ?max_ttl state db = +let create state db = let validators : net_validator Lwt.t Net_id.Table.t = Net_id.Table.create 7 in @@ -908,13 +908,13 @@ let create ?max_ttl state db = end in return (hash, validation) in - let rec activate ?parent net = + let rec activate ?parent ?max_child_ttl net = let net_id = State.Net.id net in lwt_log_notice "activate network %a" Net_id.pp net_id >>= fun () -> get net_id >>= function | Error _ -> - let v = create_validator ?max_ttl ?parent worker state db net in + let v = create_validator ?max_child_ttl ?parent worker state db net in Net_id.Table.add validators net_id v ; v | Ok v -> Lwt.return v diff --git a/src/node/shell/validator.mli b/src/node/shell/validator.mli index 9dc8312c1..26868554e 100644 --- a/src/node/shell/validator.mli +++ b/src/node/shell/validator.mli @@ -9,7 +9,7 @@ type t -val create: ?max_ttl:int -> State.t -> Distributed_db.t -> t +val create: State.t -> Distributed_db.t -> t val shutdown: t -> unit Lwt.t val notify_block: t -> Block_hash.t -> Block_header.t -> unit Lwt.t @@ -20,7 +20,7 @@ type error += | Non_increasing_timestamp | Non_increasing_fitness -val activate: t -> State.Net.t -> net_validator Lwt.t +val activate: t -> ?max_child_ttl:int -> State.Net.t -> net_validator Lwt.t val get: t -> Net_id.t -> net_validator tzresult Lwt.t val get_exn: t -> Net_id.t -> net_validator Lwt.t val deactivate: net_validator -> unit Lwt.t