P2p: add network/identity
RPC
This commit is contained in:
parent
bc37fde73e
commit
9d1bf10b94
@ -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 ->
|
||||
|
@ -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
|
||||
|
@ -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 () () ()
|
||||
|
@ -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 :
|
||||
|
Loading…
Reference in New Issue
Block a user