Client refactor: Move Client_node_rpcs.Protocols
into Protocols_services
This commit is contained in:
parent
37e65d93e7
commit
21789be756
@ -46,14 +46,4 @@ let describe cctxt ?(recurse = true) path =
|
|||||||
Shell_services.describe
|
Shell_services.describe
|
||||||
((), path) { recurse } ()
|
((), path) { recurse } ()
|
||||||
|
|
||||||
module Protocols = struct
|
|
||||||
|
|
||||||
let contents cctxt hash =
|
|
||||||
call_service1 cctxt Protocol_services.contents hash ()
|
|
||||||
|
|
||||||
let list cctxt ?contents () =
|
|
||||||
call_service0
|
|
||||||
cctxt Protocol_services.list
|
|
||||||
{ contents; monitor = Some false }
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -38,16 +38,6 @@ val inject_protocol:
|
|||||||
Protocol.t ->
|
Protocol.t ->
|
||||||
Protocol_hash.t tzresult Lwt.t
|
Protocol_hash.t tzresult Lwt.t
|
||||||
|
|
||||||
module Protocols : sig
|
|
||||||
|
|
||||||
val contents:
|
|
||||||
#Client_rpcs.ctxt ->
|
|
||||||
Protocol_hash.t -> Protocol.t tzresult Lwt.t
|
|
||||||
|
|
||||||
val list:
|
|
||||||
#Client_rpcs.ctxt ->
|
|
||||||
?contents:bool -> unit ->
|
|
||||||
(Protocol_hash.t * Protocol.t option) list tzresult Lwt.t
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ let commands () =
|
|||||||
no_options
|
no_options
|
||||||
(prefixes [ "list" ; "protocols" ] stop)
|
(prefixes [ "list" ; "protocols" ] stop)
|
||||||
(fun () (cctxt : Client_commands.full_context) ->
|
(fun () (cctxt : Client_commands.full_context) ->
|
||||||
Client_node_rpcs.Protocols.list cctxt ~contents:false () >>=? fun protos ->
|
Protocol_services.list ~contents:false cctxt >>=? fun protos ->
|
||||||
Lwt_list.iter_s (fun (ph, _p) -> cctxt#message "%a" Protocol_hash.pp ph) protos >>= fun () ->
|
Lwt_list.iter_s (fun (ph, _p) -> cctxt#message "%a" Protocol_hash.pp ph) protos >>= fun () ->
|
||||||
return ()
|
return ()
|
||||||
);
|
);
|
||||||
@ -59,7 +59,7 @@ let commands () =
|
|||||||
@@ Protocol_hash.param ~name:"protocol hash" ~desc:""
|
@@ Protocol_hash.param ~name:"protocol hash" ~desc:""
|
||||||
@@ stop)
|
@@ stop)
|
||||||
(fun () ph (cctxt : Client_commands.full_context) ->
|
(fun () ph (cctxt : Client_commands.full_context) ->
|
||||||
Client_node_rpcs.Protocols.contents cctxt ph >>=? fun proto ->
|
Protocol_services.contents cctxt ph >>=? fun proto ->
|
||||||
Lwt_utils_unix.Protocol.write_dir (Protocol_hash.to_short_b58check ph) ~hash:ph proto >>=? fun () ->
|
Lwt_utils_unix.Protocol.write_dir (Protocol_hash.to_short_b58check ph) ~hash:ph proto >>=? fun () ->
|
||||||
cctxt#message "Extracted protocol %a" Protocol_hash.pp_short ph >>= fun () ->
|
cctxt#message "Extracted protocol %a" Protocol_hash.pp_short ph >>= fun () ->
|
||||||
return ()
|
return ()
|
||||||
|
@ -331,7 +331,7 @@ let unmark_invalid node block () () =
|
|||||||
Node.RPC.unmark_invalid node block >>= fun x ->
|
Node.RPC.unmark_invalid node block >>= fun x ->
|
||||||
RPC_answer.return x
|
RPC_answer.return x
|
||||||
|
|
||||||
let list_protocols node () { Protocol_services.monitor ; contents } =
|
let list_protocols node () { Protocol_services.S.monitor ; contents } =
|
||||||
let monitor = match monitor with None -> false | Some x -> x in
|
let monitor = match monitor with None -> false | Some x -> x in
|
||||||
let include_contents = match contents with None -> false | Some x -> x in
|
let include_contents = match contents with None -> false | Some x -> x in
|
||||||
Node.RPC.protocols node >>= fun protocols ->
|
Node.RPC.protocols node >>= fun protocols ->
|
||||||
@ -391,10 +391,10 @@ let build_rpc_directory node =
|
|||||||
"All the RPCs which are specific to the protocol version."
|
"All the RPCs which are specific to the protocol version."
|
||||||
dir Block_services.S.proto_path implementation in
|
dir Block_services.S.proto_path implementation in
|
||||||
let dir =
|
let dir =
|
||||||
RPC_directory.register0 dir Protocol_services.list
|
RPC_directory.register0 dir Protocol_services.S.list
|
||||||
(list_protocols node) in
|
(list_protocols node) in
|
||||||
let dir =
|
let dir =
|
||||||
RPC_directory.register1 dir Protocol_services.contents
|
RPC_directory.register1 dir Protocol_services.S.contents
|
||||||
(get_protocols node) in
|
(get_protocols node) in
|
||||||
let dir =
|
let dir =
|
||||||
let implementation () header =
|
let implementation () header =
|
||||||
|
@ -9,9 +9,12 @@
|
|||||||
|
|
||||||
open Data_encoding
|
open Data_encoding
|
||||||
|
|
||||||
let protocols_arg = Protocol_hash.rpc_arg
|
|
||||||
|
|
||||||
let contents =
|
module S = struct
|
||||||
|
|
||||||
|
let protocols_arg = Protocol_hash.rpc_arg
|
||||||
|
|
||||||
|
let contents =
|
||||||
RPC_service.post_service
|
RPC_service.post_service
|
||||||
~query: RPC_query.empty
|
~query: RPC_query.empty
|
||||||
~input: empty
|
~input: empty
|
||||||
@ -21,12 +24,12 @@ let contents =
|
|||||||
(Protocol.encoding))))
|
(Protocol.encoding))))
|
||||||
RPC_path.(root / "protocols" /: protocols_arg)
|
RPC_path.(root / "protocols" /: protocols_arg)
|
||||||
|
|
||||||
type list_param = {
|
type list_param = {
|
||||||
contents: bool option ;
|
contents: bool option ;
|
||||||
monitor: bool option ;
|
monitor: bool option ;
|
||||||
}
|
}
|
||||||
|
|
||||||
let list_param_encoding =
|
let list_param_encoding =
|
||||||
conv
|
conv
|
||||||
(fun {contents; monitor} -> (contents, monitor))
|
(fun {contents; monitor} -> (contents, monitor))
|
||||||
(fun (contents, monitor) -> {contents; monitor})
|
(fun (contents, monitor) -> {contents; monitor})
|
||||||
@ -34,7 +37,7 @@ let list_param_encoding =
|
|||||||
(opt "contents" bool)
|
(opt "contents" bool)
|
||||||
(opt "monitor" bool))
|
(opt "monitor" bool))
|
||||||
|
|
||||||
let list =
|
let list =
|
||||||
RPC_service.post_service
|
RPC_service.post_service
|
||||||
~query: RPC_query.empty
|
~query: RPC_query.empty
|
||||||
~input: list_param_encoding
|
~input: list_param_encoding
|
||||||
@ -48,3 +51,16 @@ let list =
|
|||||||
(dynamic_size Protocol.encoding)))
|
(dynamic_size Protocol.encoding)))
|
||||||
)))
|
)))
|
||||||
RPC_path.(root / "protocols")
|
RPC_path.(root / "protocols")
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
open RPC_context
|
||||||
|
let contents ctxt h =
|
||||||
|
make_call1 S.contents ctxt h () ()
|
||||||
|
let monitor ?(contents = false) ctxt =
|
||||||
|
make_streamed_call S.list ctxt () ()
|
||||||
|
{ contents = Some contents ; monitor = Some true }
|
||||||
|
let list ?(contents = false) ctxt =
|
||||||
|
make_call S.list ctxt () ()
|
||||||
|
{ contents = Some contents ; monitor = Some false }
|
||||||
|
|
||||||
|
@ -7,17 +7,36 @@
|
|||||||
(* *)
|
(* *)
|
||||||
(**************************************************************************)
|
(**************************************************************************)
|
||||||
|
|
||||||
|
open RPC_context
|
||||||
|
|
||||||
val contents:
|
val contents:
|
||||||
|
#simple -> Protocol_hash.t -> Protocol.t tzresult Lwt.t
|
||||||
|
|
||||||
|
val list:
|
||||||
|
?contents:bool ->
|
||||||
|
#simple ->
|
||||||
|
(Protocol_hash.t * Protocol.t option) list tzresult Lwt.t
|
||||||
|
|
||||||
|
val monitor:
|
||||||
|
?contents:bool ->
|
||||||
|
#streamed ->
|
||||||
|
((Protocol_hash.t * Protocol.t option) list Lwt_stream.t * stopper) tzresult Lwt.t
|
||||||
|
|
||||||
|
module S : sig
|
||||||
|
|
||||||
|
val contents:
|
||||||
([ `POST ], unit,
|
([ `POST ], unit,
|
||||||
unit * Protocol_hash.t, unit, unit,
|
unit * Protocol_hash.t, unit, unit,
|
||||||
Protocol.t) RPC_service.t
|
Protocol.t) RPC_service.t
|
||||||
|
|
||||||
type list_param = {
|
type list_param = {
|
||||||
contents: bool option ;
|
contents: bool option ;
|
||||||
monitor: bool option ;
|
monitor: bool option ;
|
||||||
}
|
}
|
||||||
|
|
||||||
val list:
|
val list:
|
||||||
([ `POST ], unit,
|
([ `POST ], unit,
|
||||||
unit, unit, list_param,
|
unit, unit, list_param,
|
||||||
(Protocol_hash.t * Protocol.t option) list) RPC_service.t
|
(Protocol_hash.t * Protocol.t option) list) RPC_service.t
|
||||||
|
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user