Node: check that the size of known_peer_ids
is coherent
This commit is contained in:
parent
c0d42c8f46
commit
41fe7d17ea
@ -731,8 +731,52 @@ let check_bootstrap_peer addr =
|
|||||||
let check_bootstrap_peers config =
|
let check_bootstrap_peers config =
|
||||||
Lwt_list.iter_p check_bootstrap_peer config.p2p.bootstrap_peers
|
Lwt_list.iter_p check_bootstrap_peer config.p2p.bootstrap_peers
|
||||||
|
|
||||||
|
|
||||||
|
let fail fmt =
|
||||||
|
Format.kasprintf (fun s -> prerr_endline s ; exit 1) fmt
|
||||||
|
|
||||||
|
let check_connections config =
|
||||||
|
if config.p2p.limits.min_connections > config.p2p.limits.expected_connections then
|
||||||
|
fail "Error: The minumum number of connections is greater than \
|
||||||
|
the expected number of connections"
|
||||||
|
config.p2p.limits.min_connections
|
||||||
|
config.p2p.limits.expected_connections ;
|
||||||
|
if config.p2p.limits.expected_connections > config.p2p.limits.max_connections then
|
||||||
|
fail "Error: The expected number of connections is greater than \
|
||||||
|
the maximum number of connections"
|
||||||
|
config.p2p.limits.expected_connections
|
||||||
|
config.p2p.limits.max_connections ;
|
||||||
|
begin
|
||||||
|
match config.p2p.limits.max_known_peer_ids with
|
||||||
|
| None -> ()
|
||||||
|
| Some (max_known_peer_ids, target_known_peer_ids) ->
|
||||||
|
if target_known_peer_ids > max_known_peer_ids then
|
||||||
|
fail "Error: The target number of known peer ids is greater than \
|
||||||
|
the maximum number of known peer ids."
|
||||||
|
target_known_peer_ids max_known_peer_ids ;
|
||||||
|
if config.p2p.limits.max_connections > target_known_peer_ids then
|
||||||
|
fail "Error: The target number of known peer ids is lower than \
|
||||||
|
the maximum number of connections."
|
||||||
|
target_known_peer_ids max_known_peer_ids ;
|
||||||
|
end ;
|
||||||
|
begin
|
||||||
|
match config.p2p.limits.max_known_points with
|
||||||
|
| None -> ()
|
||||||
|
| Some (max_known_points, target_known_points) ->
|
||||||
|
if target_known_points > max_known_points then
|
||||||
|
fail "Error: The target number of known points is greater than \
|
||||||
|
the maximum number of known points."
|
||||||
|
target_known_points max_known_points ;
|
||||||
|
if config.p2p.limits.max_connections > target_known_points then
|
||||||
|
fail "Error: The target number of known points is lower than \
|
||||||
|
the maximum number of connections."
|
||||||
|
target_known_points max_known_points ;
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
let check config =
|
let check config =
|
||||||
check_listening_addr config >>= fun () ->
|
check_listening_addr config >>= fun () ->
|
||||||
check_rpc_listening_addr config >>= fun () ->
|
check_rpc_listening_addr config >>= fun () ->
|
||||||
check_bootstrap_peers config >>= fun () ->
|
check_bootstrap_peers config >>= fun () ->
|
||||||
|
check_connections config ;
|
||||||
Lwt.return_unit
|
Lwt.return_unit
|
||||||
|
Loading…
Reference in New Issue
Block a user