Node/Validator: minor renaming

This commit is contained in:
Grégoire Henry 2017-09-29 18:43:13 +02:00 committed by Benjamin Canou
parent 22fd758239
commit 57109435d5
3 changed files with 13 additions and 13 deletions

View File

@ -101,15 +101,15 @@ let may_create_net state genesis =
let create { genesis ; store_root ; context_root ; let create { genesis ; store_root ; context_root ;
patch_context ; p2p = net_params ; patch_context ; p2p = net_params ;
test_network_max_tll = max_ttl } = test_network_max_tll = max_child_ttl } =
init_p2p net_params >>=? fun p2p -> init_p2p net_params >>=? fun p2p ->
State.read State.read
~store_root ~context_root ?patch_context () >>=? fun state -> ~store_root ~context_root ?patch_context () >>=? fun state ->
let distributed_db = Distributed_db.create state p2p in let distributed_db = Distributed_db.create state p2p in
let validator = let validator = Validator.create state distributed_db in
Validator.create ?max_ttl state distributed_db in
may_create_net state genesis >>= fun mainnet_net -> 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 mainnet_db = Validator.net_db mainnet_validator in
let shutdown () = let shutdown () =
State.close state >>= fun () -> State.close state >>= fun () ->

View File

@ -10,7 +10,7 @@
open Logging.Node.Validator open Logging.Node.Validator
type t = { 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: Net_id.t -> net_validator tzresult Lwt.t ;
get_exn: Net_id.t -> net_validator Lwt.t ; get_exn: Net_id.t -> net_validator Lwt.t ;
deactivate: net_validator -> unit Lwt.t ; deactivate: net_validator -> unit Lwt.t ;
@ -48,7 +48,7 @@ and net_validator = {
let net_state { net } = net let net_state { net } = net
let net_db { net_db } = net_db 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 deactivate net_validator = net_validator.worker.deactivate net_validator
let get w = w.get let get w = w.get
let get_exn w = w.get_exn let get_exn w = w.get_exn
@ -605,7 +605,7 @@ module Context_db = struct
end 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 queue = Lwt_pipe.create () in
let current_ops = ref (fun () -> []) in let current_ops = ref (fun () -> []) in
@ -744,7 +744,7 @@ let rec create_validator ?max_ttl ?parent worker state db net =
| Some child -> | Some child ->
Block_hash.equal (State.Net.genesis child.net).block genesis in Block_hash.equal (State.Net.genesis child.net).block genesis in
begin begin
match max_ttl with match max_child_ttl with
| None -> Lwt.return expiration | None -> Lwt.return expiration
| Some ttl -> | Some ttl ->
Distributed_db.Block_header.fetch net_db genesis () >>= fun genesis -> 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 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 = let validators : net_validator Lwt.t Net_id.Table.t =
Net_id.Table.create 7 in Net_id.Table.create 7 in
@ -908,13 +908,13 @@ let create ?max_ttl state db =
end in end in
return (hash, validation) 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 let net_id = State.Net.id net in
lwt_log_notice "activate network %a" lwt_log_notice "activate network %a"
Net_id.pp net_id >>= fun () -> Net_id.pp net_id >>= fun () ->
get net_id >>= function get net_id >>= function
| Error _ -> | 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 ; Net_id.Table.add validators net_id v ;
v v
| Ok v -> Lwt.return v | Ok v -> Lwt.return v

View File

@ -9,7 +9,7 @@
type t 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 shutdown: t -> unit Lwt.t
val notify_block: t -> Block_hash.t -> Block_header.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_timestamp
| Non_increasing_fitness | 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: t -> Net_id.t -> net_validator tzresult Lwt.t
val get_exn: t -> Net_id.t -> net_validator Lwt.t val get_exn: t -> Net_id.t -> net_validator Lwt.t
val deactivate: net_validator -> unit Lwt.t val deactivate: net_validator -> unit Lwt.t