Shell: add CLI options for bootstrap_threshold
This commit is contained in:
parent
f3555488c7
commit
910b43726b
11
README.md
11
README.md
@ -334,6 +334,17 @@ help writing your own configuration file if needed.
|
|||||||
http://ocsigen.org/lwt/dev/api/Lwt_log_core#2_Logtemplates. */
|
http://ocsigen.org/lwt/dev/api/Lwt_log_core#2_Logtemplates. */
|
||||||
|
|
||||||
"template": "$(date) - $(section): $(message)"
|
"template": "$(date) - $(section): $(message)"
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Configuration for the validator and mempool parameters */
|
||||||
|
|
||||||
|
"shell": {
|
||||||
|
|
||||||
|
/* The number of peers to synchronize with
|
||||||
|
before declaring the node 'bootstrapped'. */
|
||||||
|
|
||||||
|
"bootstrap_threshold": 4
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -22,6 +22,7 @@ type t = {
|
|||||||
net : net ;
|
net : net ;
|
||||||
rpc : rpc ;
|
rpc : rpc ;
|
||||||
log : log ;
|
log : log ;
|
||||||
|
shell : shell ;
|
||||||
}
|
}
|
||||||
|
|
||||||
and net = {
|
and net = {
|
||||||
@ -51,6 +52,10 @@ and log = {
|
|||||||
template : Logging.template ;
|
template : Logging.template ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
and shell = {
|
||||||
|
bootstrap_threshold : int ;
|
||||||
|
}
|
||||||
|
|
||||||
let default_net_limits : P2p.limits = {
|
let default_net_limits : P2p.limits = {
|
||||||
authentification_timeout = 5. ;
|
authentification_timeout = 5. ;
|
||||||
min_connections = 10 ;
|
min_connections = 10 ;
|
||||||
@ -96,11 +101,16 @@ let default_log = {
|
|||||||
template = Logging.default_template ;
|
template = Logging.default_template ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let default_shell = {
|
||||||
|
bootstrap_threshold = 4 ;
|
||||||
|
}
|
||||||
|
|
||||||
let default_config = {
|
let default_config = {
|
||||||
data_dir = default_data_dir ;
|
data_dir = default_data_dir ;
|
||||||
net = default_net ;
|
net = default_net ;
|
||||||
rpc = default_rpc ;
|
rpc = default_rpc ;
|
||||||
log = default_log ;
|
log = default_log ;
|
||||||
|
shell = default_shell ;
|
||||||
}
|
}
|
||||||
|
|
||||||
let limit : P2p.limits Data_encoding.t =
|
let limit : P2p.limits Data_encoding.t =
|
||||||
@ -235,16 +245,27 @@ let log =
|
|||||||
(opt "rules" string)
|
(opt "rules" string)
|
||||||
(dft "template" string default_log.template))
|
(dft "template" string default_log.template))
|
||||||
|
|
||||||
|
let shell =
|
||||||
|
let open Data_encoding in
|
||||||
|
conv
|
||||||
|
(fun { bootstrap_threshold } -> bootstrap_threshold)
|
||||||
|
(fun bootstrap_threshold -> { bootstrap_threshold })
|
||||||
|
(obj1
|
||||||
|
(dft "bootstrap_threshold" uint8 default_shell.bootstrap_threshold))
|
||||||
|
|
||||||
let encoding =
|
let encoding =
|
||||||
let open Data_encoding in
|
let open Data_encoding in
|
||||||
conv
|
conv
|
||||||
(fun { data_dir ; rpc ; net ; log } -> (data_dir, rpc, net, log))
|
(fun { data_dir ; rpc ; net ; log ; shell } ->
|
||||||
(fun (data_dir, rpc, net, log) -> { data_dir ; rpc ; net ; log })
|
(data_dir, rpc, net, log, shell))
|
||||||
(obj4
|
(fun (data_dir, rpc, net, log, shell) ->
|
||||||
|
{ data_dir ; rpc ; net ; log ; shell })
|
||||||
|
(obj5
|
||||||
(dft "data-dir" string default_data_dir)
|
(dft "data-dir" string default_data_dir)
|
||||||
(dft "rpc" rpc default_rpc)
|
(dft "rpc" rpc default_rpc)
|
||||||
(req "net" net)
|
(req "net" net)
|
||||||
(dft "log" log default_log))
|
(dft "log" log default_log)
|
||||||
|
(dft "shell" shell default_shell))
|
||||||
|
|
||||||
let read fp =
|
let read fp =
|
||||||
if Sys.file_exists fp then begin
|
if Sys.file_exists fp then begin
|
||||||
@ -281,6 +302,7 @@ let update
|
|||||||
?(cors_headers = [])
|
?(cors_headers = [])
|
||||||
?rpc_tls
|
?rpc_tls
|
||||||
?log_output
|
?log_output
|
||||||
|
?bootstrap_threshold
|
||||||
cfg =
|
cfg =
|
||||||
let data_dir = Utils.unopt ~default:cfg.data_dir data_dir in
|
let data_dir = Utils.unopt ~default:cfg.data_dir data_dir in
|
||||||
Node_data_version.ensure_data_dir data_dir >>=? fun () ->
|
Node_data_version.ensure_data_dir data_dir >>=? fun () ->
|
||||||
@ -342,8 +364,14 @@ let update
|
|||||||
cfg.log with
|
cfg.log with
|
||||||
output = Utils.unopt ~default:cfg.log.output log_output ;
|
output = Utils.unopt ~default:cfg.log.output log_output ;
|
||||||
}
|
}
|
||||||
|
and shell : shell = {
|
||||||
|
bootstrap_threshold =
|
||||||
|
Utils.unopt
|
||||||
|
~default:cfg.shell.bootstrap_threshold
|
||||||
|
bootstrap_threshold ;
|
||||||
|
}
|
||||||
in
|
in
|
||||||
return { data_dir ; net ; rpc ; log }
|
return { data_dir ; net ; rpc ; log ; shell }
|
||||||
|
|
||||||
let resolve_addr ?default_port ?(passive = false) peer =
|
let resolve_addr ?default_port ?(passive = false) peer =
|
||||||
let addr, port = Utils.parse_addr_port peer in
|
let addr, port = Utils.parse_addr_port peer in
|
||||||
|
@ -12,6 +12,7 @@ type t = {
|
|||||||
net : net ;
|
net : net ;
|
||||||
rpc : rpc ;
|
rpc : rpc ;
|
||||||
log : log ;
|
log : log ;
|
||||||
|
shell : shell ;
|
||||||
}
|
}
|
||||||
|
|
||||||
and net = {
|
and net = {
|
||||||
@ -41,6 +42,10 @@ and log = {
|
|||||||
template : Logging.template ;
|
template : Logging.template ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
and shell = {
|
||||||
|
bootstrap_threshold : int ;
|
||||||
|
}
|
||||||
|
|
||||||
val default_data_dir: string
|
val default_data_dir: string
|
||||||
val default_net_port: int
|
val default_net_port: int
|
||||||
val default_rpc_port: int
|
val default_rpc_port: int
|
||||||
@ -65,6 +70,7 @@ val update:
|
|||||||
?cors_headers:string list ->
|
?cors_headers:string list ->
|
||||||
?rpc_tls:tls ->
|
?rpc_tls:tls ->
|
||||||
?log_output:Logging.Output.t ->
|
?log_output:Logging.Output.t ->
|
||||||
|
?bootstrap_threshold:int ->
|
||||||
t -> t tzresult Lwt.t
|
t -> t tzresult Lwt.t
|
||||||
|
|
||||||
val to_string: t -> string
|
val to_string: t -> string
|
||||||
|
@ -142,7 +142,7 @@ let init_node ?sandbox (config : Node_config_file.t) =
|
|||||||
context_root = context_dir config.data_dir ;
|
context_root = context_dir config.data_dir ;
|
||||||
p2p = p2p_config ;
|
p2p = p2p_config ;
|
||||||
test_network_max_tll = Some (48 * 3600) ; (* 2 days *)
|
test_network_max_tll = Some (48 * 3600) ; (* 2 days *)
|
||||||
bootstrap_threshold = 4 ; (* TODO add parameter *)
|
bootstrap_threshold = config.shell.bootstrap_threshold ;
|
||||||
} in
|
} in
|
||||||
Node.create node_config
|
Node.create node_config
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ type t = {
|
|||||||
cors_headers: string list ;
|
cors_headers: string list ;
|
||||||
rpc_tls: Node_config_file.tls option ;
|
rpc_tls: Node_config_file.tls option ;
|
||||||
log_output: Logging.Output.t option ;
|
log_output: Logging.Output.t option ;
|
||||||
|
bootstrap_threshold: int option ;
|
||||||
}
|
}
|
||||||
|
|
||||||
let wrap
|
let wrap
|
||||||
@ -55,10 +56,11 @@ let wrap
|
|||||||
|
|
||||||
(* when `--expected-connections` is used,
|
(* when `--expected-connections` is used,
|
||||||
override all the bounds defined in the configuration file. *)
|
override all the bounds defined in the configuration file. *)
|
||||||
let min_connections, expected_connections, max_connections =
|
let bootstrap_threshold,
|
||||||
|
min_connections, expected_connections, max_connections =
|
||||||
match connections with
|
match connections with
|
||||||
| None -> None, None, None
|
| None -> None, None, None, None
|
||||||
| Some x -> Some (x/2), Some x, Some (3*x/2) in
|
| Some x -> Some (min (x/4) 2), Some (x/2), Some x, Some (3*x/2) in
|
||||||
|
|
||||||
{ data_dir ;
|
{ data_dir ;
|
||||||
config_file ;
|
config_file ;
|
||||||
@ -79,6 +81,7 @@ let wrap
|
|||||||
rpc_tls ;
|
rpc_tls ;
|
||||||
log_output ;
|
log_output ;
|
||||||
peer_table_size ;
|
peer_table_size ;
|
||||||
|
bootstrap_threshold ;
|
||||||
}
|
}
|
||||||
|
|
||||||
module Manpage = struct
|
module Manpage = struct
|
||||||
@ -258,7 +261,9 @@ let read_and_patch_config_file ?(ignore_bootstrap_peers=false) args =
|
|||||||
listen_addr ; closed ;
|
listen_addr ; closed ;
|
||||||
rpc_listen_addr ; rpc_tls ;
|
rpc_listen_addr ; rpc_tls ;
|
||||||
cors_origins ; cors_headers ;
|
cors_origins ; cors_headers ;
|
||||||
log_output } = args in
|
log_output ;
|
||||||
|
bootstrap_threshold ;
|
||||||
|
} = args in
|
||||||
let bootstrap_peers =
|
let bootstrap_peers =
|
||||||
if no_bootstrap_peers || ignore_bootstrap_peers
|
if no_bootstrap_peers || ignore_bootstrap_peers
|
||||||
then begin
|
then begin
|
||||||
@ -271,4 +276,5 @@ let read_and_patch_config_file ?(ignore_bootstrap_peers=false) args =
|
|||||||
?max_download_speed ?max_upload_speed ?binary_chunks_size
|
?max_download_speed ?max_upload_speed ?binary_chunks_size
|
||||||
?peer_table_size ?expected_pow
|
?peer_table_size ?expected_pow
|
||||||
~bootstrap_peers ?listen_addr ?rpc_listen_addr
|
~bootstrap_peers ?listen_addr ?rpc_listen_addr
|
||||||
~closed ~cors_origins ~cors_headers ?rpc_tls ?log_output cfg
|
~closed ~cors_origins ~cors_headers ?rpc_tls ?log_output
|
||||||
|
?bootstrap_threshold cfg
|
||||||
|
@ -27,6 +27,7 @@ type t = {
|
|||||||
cors_headers: string list ;
|
cors_headers: string list ;
|
||||||
rpc_tls: Node_config_file.tls option ;
|
rpc_tls: Node_config_file.tls option ;
|
||||||
log_output: Logging.Output.t option ;
|
log_output: Logging.Output.t option ;
|
||||||
|
bootstrap_threshold: int option ;
|
||||||
}
|
}
|
||||||
|
|
||||||
module Term : sig
|
module Term : sig
|
||||||
|
Loading…
Reference in New Issue
Block a user