Commit c577b507 authored by Philippe B.'s avatar Philippe B. 🏂 Committed by Romain

P2p/Shell: move options from p2p to shell config

Options disable_testchain and disable_mempool shouldn't belong
to the P2p configuration. They are moved to the node configuration.
parent 38cb05b2
......@@ -51,6 +51,8 @@ let with_node f =
protocol_root = dir / "protocol";
p2p = None;
checkpoint = None;
disable_mempool = true;
disable_testchain = true;
}
in
Node.create
......
......@@ -134,9 +134,7 @@ let init_node ?sandbox ?checkpoint ~singleprocess (config : Node_config_file.t)
greylisting_config = config.p2p.greylisting_config;
identity;
proof_of_work_target = Crypto_box.make_target config.p2p.expected_pow;
disable_mempool = config.p2p.disable_mempool;
trust_discovered_peers = sandbox <> None;
disable_testchain = config.p2p.disable_testchain;
}
in
return_some (p2p_config, config.p2p.limits) )
......@@ -171,6 +169,8 @@ let init_node ?sandbox ?checkpoint ~singleprocess (config : Node_config_file.t)
protocol_root = Node_data_version.protocol_dir config.data_dir;
p2p = p2p_config;
checkpoint;
disable_testchain = config.p2p.disable_testchain;
disable_mempool = config.p2p.disable_mempool;
}
in
Node.create
......
......@@ -38,9 +38,7 @@ type config = {
private_mode : bool;
identity : P2p_identity.t;
proof_of_work_target : Crypto_box.target;
disable_mempool : bool;
trust_discovered_peers : bool;
disable_testchain : bool;
greylisting_config : P2p_point_state.Info.greylisting_config;
}
......
......@@ -99,14 +99,8 @@ type config = {
identity : P2p_identity.t; (** Cryptographic identity of the peer. *)
proof_of_work_target : Crypto_box.target;
(** Expected level of proof of work of peers' identity. *)
disable_mempool : bool;
(** If [true], all non-empty mempools will be ignored. *)
(* TODO this option is unused in lib_p2p. Should be moved outside the lib. *)
trust_discovered_peers : bool;
(** If [true], peers discovered on the local network will be trusted. *)
disable_testchain : bool;
(** If [true], testchain related messages will be ignored. *)
(* TODO this option is unused in lib_p2p. Should be moved outside the lib. *)
greylisting_config : P2p_point_state.Info.greylisting_config;
(** The greylisting configuration. *)
}
......
......@@ -111,27 +111,24 @@ let connection_metadata_cfg cfg : _ P2p_params.conn_meta_config =
conn_meta_value = (fun () -> cfg);
}
let init_connection_metadata opt =
let init_connection_metadata opt disable_mempool =
let open Connection_metadata in
match opt with
| None ->
{disable_mempool = false; private_node = false}
| Some c ->
{
disable_mempool = c.P2p.disable_mempool;
private_node = c.P2p.private_mode;
}
{disable_mempool; private_node = c.P2p.private_mode}
let init_p2p chain_name p2p_params =
let init_p2p chain_name p2p_params disable_mempool =
let message_cfg = Distributed_db_message.cfg chain_name in
match p2p_params with
| None ->
let c_meta = init_connection_metadata None in
let c_meta = init_connection_metadata None disable_mempool in
Initialization_event.lwt_emit `P2p_layer_disabled
>>= fun () ->
return (P2p.faked_network message_cfg peer_metadata_cfg c_meta)
| Some (config, limits) ->
let c_meta = init_connection_metadata (Some config) in
let c_meta = init_connection_metadata (Some config) disable_mempool in
let conn_metadata_cfg = connection_metadata_cfg c_meta in
Initialization_event.lwt_emit `Bootstrapping
>>= fun () ->
......@@ -157,6 +154,8 @@ type config = {
patch_context : (Context.t -> Context.t Lwt.t) option;
p2p : (P2p.config * P2p.limits) option;
checkpoint : Block_header.t option;
disable_mempool : bool;
disable_testchain : bool;
}
and peer_validator_limits = Peer_validator.limits = {
......@@ -325,16 +324,21 @@ let create ?(sandboxed = false) ?sandbox_parameters ~singleprocess
protocol_root;
patch_context;
p2p = p2p_params;
disable_mempool;
disable_testchain;
checkpoint } peer_validator_limits block_validator_limits
prevalidator_limits chain_validator_limits history_mode =
let (start_prevalidator, start_testchain) =
match p2p_params with
| Some (config, _limits) ->
(not config.P2p.disable_mempool, not config.P2p.disable_testchain)
| Some _ ->
(not disable_mempool, not disable_testchain)
| None ->
(true, true)
in
init_p2p (if sandboxed then sandboxed_chain_name else chain_name) p2p_params
init_p2p
(if sandboxed then sandboxed_chain_name else chain_name)
p2p_params
disable_mempool
>>=? fun p2p ->
(let open Block_validator_process in
if singleprocess then
......
......@@ -39,6 +39,10 @@ type config = {
patch_context : (Context.t -> Context.t Lwt.t) option;
p2p : (P2p.config * P2p.limits) option;
checkpoint : Block_header.t option;
disable_mempool : bool;
(** If [true], all non-empty mempools will be ignored. *)
disable_testchain : bool;
(** If [true], testchain related messages will be ignored. *)
}
and peer_validator_limits = {
......
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