diff --git a/src/bin_node/node_config_command.ml b/src/bin_node/node_config_command.ml index ac0aa9a38..066aba35a 100644 --- a/src/bin_node/node_config_command.ml +++ b/src/bin_node/node_config_command.ml @@ -49,7 +49,7 @@ let reset (args : Node_shared_arg.t) = let init (args : Node_shared_arg.t) = if Sys.file_exists args.config_file then failwith - "Pre-existant config file at %s, use `reset`." + "Pre-existing config file at %s, use `reset`." args.config_file else Node_shared_arg.read_and_patch_config_file args >>=? fun cfg -> diff --git a/src/lib_p2p/p2p.ml b/src/lib_p2p/p2p.ml index 6db94efe6..c297346f2 100644 --- a/src/lib_p2p/p2p.ml +++ b/src/lib_p2p/p2p.ml @@ -578,6 +578,13 @@ let build_rpc_directory net = return net.versions end in + let dir = + RPC_directory.register0 dir P2p_services.S.identity begin fun () () -> + match net.pool with + | None -> failwith "The P2P layer is disabled." + | Some pool -> return (P2p_pool.config pool).identity.peer_id + end in + let dir = RPC_directory.register0 dir P2p_services.S.stat begin fun () () -> match net.pool with diff --git a/src/lib_shell_services/p2p_services.ml b/src/lib_shell_services/p2p_services.ml index 6f43876f9..78e2dc867 100644 --- a/src/lib_shell_services/p2p_services.ml +++ b/src/lib_shell_services/p2p_services.ml @@ -49,6 +49,13 @@ let timeout_query = module S = struct + let identity = + RPC_service.get_service + ~description:"Return the node's identity" + ~query: RPC_query.empty + ~output: P2p_peer.Id.encoding + RPC_path.(root / "network" / "identity") + let versions = RPC_service.get_service ~description:"Supported network layer versions." @@ -81,6 +88,7 @@ module S = struct end open RPC_context +let identity ctxt = make_call S.identity ctxt () () () let stat ctxt = make_call S.stat ctxt () () () let versions ctxt = make_call S.versions ctxt () () () let events ctxt = make_streamed_call S.events ctxt () () () diff --git a/src/lib_shell_services/p2p_services.mli b/src/lib_shell_services/p2p_services.mli index 83e531a6c..ef93c7335 100644 --- a/src/lib_shell_services/p2p_services.mli +++ b/src/lib_shell_services/p2p_services.mli @@ -25,6 +25,8 @@ open RPC_context +val identity: #simple -> P2p_peer.Id.t tzresult Lwt.t + val stat: #simple -> P2p_stat.t tzresult Lwt.t val versions: #simple -> P2p_version.t list tzresult Lwt.t @@ -36,6 +38,11 @@ val connect: #simple -> timeout:float -> P2p_point.Id.t -> unit tzresult Lwt.t module S : sig + val identity : + ([ `GET ], unit, + unit, unit, unit, + P2p_peer.Id.t) RPC_service.t + val stat : ([ `GET ], unit, unit, unit, unit, @@ -127,7 +134,7 @@ module Points : sig val events : ([ `GET ], unit, - unit * P2p_point.Id.t, < monitor: bool>, unit, + unit * P2p_point.Id.t, < monitor: bool>, unit, P2p_point.Pool_event.t list) RPC_service.t val forget :