From db500b5ebd323574d19c65fa31bb2de876a62874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Thu, 8 Feb 2018 10:51:02 +0100 Subject: [PATCH] RPC_service: hide the 'error type parameter --- src/lib_client_base/client_rpcs.ml | 8 +-- src/lib_client_base/client_rpcs.mli | 22 ++++---- .../v1/RPC_answer.mli | 16 +++--- .../v1/RPC_directory.mli | 28 +++++----- .../v1/RPC_service.mli | 39 ++++++------- src/lib_rpc/RPC_answer.ml | 21 ++++++- src/lib_rpc/RPC_answer.mli | 21 ++++++- src/lib_rpc/RPC_directory.mli | 44 +++++++++++++++ src/lib_rpc/RPC_error.ml | 1 - src/lib_rpc/RPC_error.mli | 2 +- src/lib_rpc/RPC_service.ml | 24 +++++++- src/lib_rpc/RPC_service.mli | 54 +++++++++++++++++- src/lib_rpc_http/RPC_client.ml | 4 +- src/lib_rpc_http/RPC_client.mli | 4 +- src/lib_shell_services/block_services.ml | 18 ------ src/lib_shell_services/block_services.mli | 36 ++++++------ src/lib_shell_services/p2p_services.ml | 13 ----- src/lib_shell_services/p2p_services.mli | 26 ++++----- src/lib_shell_services/protocol_services.ml | 2 - src/lib_shell_services/protocol_services.mli | 4 +- src/lib_shell_services/shell_services.ml | 6 -- src/lib_shell_services/shell_services.mli | 12 ++-- src/lib_shell_services/worker_services.ml | 7 --- src/lib_shell_services/worker_services.mli | 18 +++--- src/proto_alpha/lib_protocol/src/services.ml | 55 ------------------- src/proto_demo/lib_protocol/src/services.ml | 2 - .../lib_protocol/src/services.ml | 1 - .../lib_resto-directory/resto_directory.mli | 4 +- 28 files changed, 267 insertions(+), 225 deletions(-) diff --git a/src/lib_client_base/client_rpcs.ml b/src/lib_client_base/client_rpcs.ml index 3c5564d97..047378e10 100644 --- a/src/lib_client_base/client_rpcs.ml +++ b/src/lib_client_base/client_rpcs.ml @@ -44,11 +44,11 @@ end class type service_ctxt = object method call_service : 'm 'p 'q 'i 'o 'e. - ([< Resto.meth ] as 'm, unit, 'p, 'q, 'i, 'o, 'e) RPC_service.t -> + ([< Resto.meth ] as 'm, unit, 'p, 'q, 'i, 'o) RPC_service.t -> 'p -> 'q -> 'i -> 'o tzresult Lwt.t method call_streamed_service : 'm 'p 'q 'i 'o 'e. - ([< Resto.meth ] as 'm, unit, 'p, 'q, 'i, 'o, 'e) RPC_service.t -> + ([< Resto.meth ] as 'm, unit, 'p, 'q, 'i, 'o) RPC_service.t -> on_chunk: ('o -> unit) -> on_close: (unit -> unit) -> 'p -> 'q -> 'i -> (unit -> unit) tzresult Lwt.t @@ -74,13 +74,13 @@ class http_ctxt config : ctxt = RPC_client.generic_json_call ~logger meth ?body uri method call_service : 'm 'p 'q 'i 'o 'e. - ([< Resto.meth ] as 'm, unit, 'p, 'q, 'i, 'o, 'e) RPC_service.t -> + ([< Resto.meth ] as 'm, unit, 'p, 'q, 'i, 'o) RPC_service.t -> 'p -> 'q -> 'i -> 'o tzresult Lwt.t = fun service params query body -> RPC_client.call_service Media_type.all_media_types ~logger ~base service params query body method call_streamed_service : 'm 'p 'q 'i 'o 'e. - ([< Resto.meth ] as 'm, unit, 'p, 'q, 'i, 'o, 'e) RPC_service.t -> + ([< Resto.meth ] as 'm, unit, 'p, 'q, 'i, 'o) RPC_service.t -> on_chunk: ('o -> unit) -> on_close: (unit -> unit) -> 'p -> 'q -> 'i -> (unit -> unit) tzresult Lwt.t = diff --git a/src/lib_client_base/client_rpcs.mli b/src/lib_client_base/client_rpcs.mli index 936d06105..74540e3fb 100644 --- a/src/lib_client_base/client_rpcs.mli +++ b/src/lib_client_base/client_rpcs.mli @@ -25,11 +25,11 @@ end class type service_ctxt = object method call_service : 'm 'p 'q 'i 'o 'e. - ([< Resto.meth ] as 'm, unit, 'p, 'q, 'i, 'o, 'e) RPC_service.t -> + ([< Resto.meth ] as 'm, unit, 'p, 'q, 'i, 'o) RPC_service.t -> 'p -> 'q -> 'i -> 'o tzresult Lwt.t method call_streamed_service : 'm 'p 'q 'i 'o 'e. - ([< Resto.meth ] as 'm, unit, 'p, 'q, 'i, 'o, 'e) RPC_service.t -> + ([< Resto.meth ] as 'm, unit, 'p, 'q, 'i, 'o) RPC_service.t -> on_chunk: ('o -> unit) -> on_close: (unit -> unit) -> 'p -> 'q -> 'i -> (unit -> unit) tzresult Lwt.t @@ -47,63 +47,63 @@ val call_service: #service_ctxt -> ('m, unit, 'p, 'q, 'i, - 'o, 'e) RPC_service.t -> + 'o) RPC_service.t -> 'p -> 'q -> 'i -> 'o tzresult Lwt.t val call_service0: #service_ctxt -> ('m, unit, unit, unit, 'i, - 'o, 'e) RPC_service.t -> + 'o) RPC_service.t -> 'i -> 'o tzresult Lwt.t val call_service1: #service_ctxt -> ('m, unit, unit * 'a, unit, 'i, - 'o, 'e) RPC_service.t -> + 'o) RPC_service.t -> 'a -> 'i -> 'o tzresult Lwt.t val call_service2: #service_ctxt -> ('m, unit, (unit * 'a) * 'b, unit, 'i, - 'o, 'e) RPC_service.t -> + 'o) RPC_service.t -> 'a -> 'b -> 'i -> 'o tzresult Lwt.t val call_streamed_service0: #service_ctxt -> ('m, unit, unit, unit, 'a, - 'b, unit) RPC_service.t -> + 'b) RPC_service.t -> 'a -> 'b Lwt_stream.t tzresult Lwt.t val call_streamed_service1: #service_ctxt -> ('m, unit, unit * 'a, unit, 'b, - 'c, unit) RPC_service.t -> + 'c) RPC_service.t -> 'a -> 'b -> 'c Lwt_stream.t tzresult Lwt.t val call_err_service0: #service_ctxt -> ('m, unit, unit, unit, 'i, - 'o tzresult, 'e) RPC_service.t -> + 'o tzresult) RPC_service.t -> 'i -> 'o tzresult Lwt.t val call_err_service1: #service_ctxt -> ('m, unit, unit * 'a, unit, 'i, - 'o tzresult, 'e) RPC_service.t -> + 'o tzresult) RPC_service.t -> 'a -> 'i -> 'o tzresult Lwt.t val call_err_service2: #service_ctxt -> ('m, unit, (unit * 'a) * 'b, unit, 'i, - 'o tzresult, 'e) RPC_service.t -> + 'o tzresult) RPC_service.t -> 'a -> 'b -> 'i -> 'o tzresult Lwt.t type block = Block_services.block diff --git a/src/lib_protocol_environment_sigs/v1/RPC_answer.mli b/src/lib_protocol_environment_sigs/v1/RPC_answer.mli index 31e960f13..0b78c33a6 100644 --- a/src/lib_protocol_environment_sigs/v1/RPC_answer.mli +++ b/src/lib_protocol_environment_sigs/v1/RPC_answer.mli @@ -8,16 +8,16 @@ (**************************************************************************) (** Return type for service handler *) -type ('o, 'e) t = +type 'o t = [ `Ok of 'o (* 200 *) | `OkStream of 'o stream (* 200 *) | `Created of string option (* 201 *) | `No_content (* 204 *) - | `Unauthorized of 'e option (* 401 *) - | `Forbidden of 'e option (* 403 *) - | `Not_found of 'e option (* 404 *) - | `Conflict of 'e option (* 409 *) - | `Error of 'e option (* 500 *) + | `Unauthorized of unit option (* 401 *) + | `Forbidden of unit option (* 403 *) + | `Not_found of unit option (* 404 *) + | `Conflict of unit option (* 409 *) + | `Error of unit option (* 500 *) ] and 'a stream = { @@ -25,5 +25,5 @@ and 'a stream = { shutdown: unit -> unit ; } -val return: 'o -> ('o, 'e) t Lwt.t -val return_stream: 'o stream -> ('o, 'e) t Lwt.t +val return: 'o -> 'o t Lwt.t +val return_stream: 'o stream -> 'o t Lwt.t diff --git a/src/lib_protocol_environment_sigs/v1/RPC_directory.mli b/src/lib_protocol_environment_sigs/v1/RPC_directory.mli index b8090a851..e5c42a050 100644 --- a/src/lib_protocol_environment_sigs/v1/RPC_directory.mli +++ b/src/lib_protocol_environment_sigs/v1/RPC_directory.mli @@ -35,43 +35,43 @@ exception Conflict of step list * conflict (** Registring handler in service tree. *) val register: 'prefix directory -> - ('meth, 'prefix, 'params, 'query, 'input, 'output, 'error) RPC_service.t -> - ('params -> 'query -> 'input -> [< ('output, 'error) RPC_answer.t ] Lwt.t) -> + ('meth, 'prefix, 'params, 'query, 'input, 'output) RPC_service.t -> + ('params -> 'query -> 'input -> [< 'output RPC_answer.t ] Lwt.t) -> 'prefix directory (** Registring handler in service tree. Curryfied variant. *) val register0: unit directory -> - ('m, unit, unit, 'q, 'i, 'o, 'e) RPC_service.t -> - ('q -> 'i -> [< ('o, 'e) RPC_answer.t ] Lwt.t) -> + ('m, unit, unit, 'q, 'i, 'o) RPC_service.t -> + ('q -> 'i -> [< 'o RPC_answer.t ] Lwt.t) -> unit directory val register1: 'prefix directory -> - ('m, 'prefix, unit * 'a, 'q , 'i, 'o, 'e) RPC_service.t -> - ('a -> 'q -> 'i -> [< ('o, 'e) RPC_answer.t ] Lwt.t) -> + ('m, 'prefix, unit * 'a, 'q , 'i, 'o) RPC_service.t -> + ('a -> 'q -> 'i -> [< 'o RPC_answer.t ] Lwt.t) -> 'prefix directory val register2: 'prefix directory -> - ('m, 'prefix, (unit * 'a) * 'b, 'q , 'i, 'o, 'e) RPC_service.t -> - ('a -> 'b -> 'q -> 'i -> [< ('o, 'e) RPC_answer.t ] Lwt.t) -> + ('m, 'prefix, (unit * 'a) * 'b, 'q , 'i, 'o) RPC_service.t -> + ('a -> 'b -> 'q -> 'i -> [< 'o RPC_answer.t ] Lwt.t) -> 'prefix directory val register3: 'prefix directory -> - ('m, 'prefix, ((unit * 'a) * 'b) * 'c, 'q , 'i, 'o, 'e) RPC_service.t -> - ('a -> 'b -> 'c -> 'q -> 'i -> [< ('o, 'e) RPC_answer.t ] Lwt.t) -> + ('m, 'prefix, ((unit * 'a) * 'b) * 'c, 'q , 'i, 'o) RPC_service.t -> + ('a -> 'b -> 'c -> 'q -> 'i -> [< 'o RPC_answer.t ] Lwt.t) -> 'prefix directory val register4: 'prefix directory -> - ('m, 'prefix, (((unit * 'a) * 'b) * 'c) * 'd, 'q , 'i, 'o, 'e) RPC_service.t -> - ('a -> 'b -> 'c -> 'd -> 'q -> 'i -> [< ('o, 'e) RPC_answer.t ] Lwt.t) -> + ('m, 'prefix, (((unit * 'a) * 'b) * 'c) * 'd, 'q , 'i, 'o) RPC_service.t -> + ('a -> 'b -> 'c -> 'd -> 'q -> 'i -> [< 'o RPC_answer.t ] Lwt.t) -> 'prefix directory val register5: 'prefix directory -> - ('m, 'prefix, ((((unit * 'a) * 'b) * 'c) * 'd) * 'e, 'q , 'i, 'o, 'e) RPC_service.t -> - ('a -> 'b -> 'c -> 'd -> 'e -> 'q -> 'i -> [< ('o, 'e) RPC_answer.t ] Lwt.t) -> + ('m, 'prefix, ((((unit * 'a) * 'b) * 'c) * 'd) * 'e, 'q , 'i, 'o) RPC_service.t -> + ('a -> 'b -> 'c -> 'd -> 'e -> 'q -> 'i -> [< 'o RPC_answer.t ] Lwt.t) -> 'prefix directory diff --git a/src/lib_protocol_environment_sigs/v1/RPC_service.mli b/src/lib_protocol_environment_sigs/v1/RPC_service.mli index 678450291..b81f53970 100644 --- a/src/lib_protocol_environment_sigs/v1/RPC_service.mli +++ b/src/lib_protocol_environment_sigs/v1/RPC_service.mli @@ -18,13 +18,13 @@ type meth = [ module MethMap : Map.S with type key = meth -type (+'meth, 'prefix, 'params, 'query, 'input, 'output, 'error) t +type (+'meth, 'prefix, 'params, 'query, 'input, 'output) t constraint 'meth = [< meth ] -type (+'meth, 'prefix, 'params, 'query, 'input, 'output, 'error) service = - ('meth, 'prefix, 'params, 'query, 'input, 'output, 'error) t +type (+'meth, 'prefix, 'params, 'query, 'input, 'output) service = + ('meth, 'prefix, 'params, 'query, 'input, 'output) t val query: - ('meth, 'prefix, 'params, 'query, 'input, 'output, 'error) service -> + ('meth, 'prefix, 'params, 'query, 'input, 'output) service -> 'query RPC_query.t type _ input = @@ -32,69 +32,64 @@ type _ input = | Input : 'input Data_encoding.t -> 'input input val input_encoding: - ('meth, 'prefix, 'params, 'query, 'input, 'output, 'error) service -> + ('meth, 'prefix, 'params, 'query, 'input, 'output) service -> 'input input val output_encoding: - ('meth, 'prefix, 'params, 'query, 'input, 'output, 'error) service -> + ('meth, 'prefix, 'params, 'query, 'input, 'output) service -> 'output Data_encoding.t val error_encoding: - ('meth, 'prefix, 'params, 'query, 'input, 'output, 'error) service -> - 'error Data_encoding.t + ('meth, 'prefix, 'params, 'query, 'input, 'output) service -> + unit Data_encoding.t val prefix: ('prefix, 'inner_prefix) RPC_path.t -> ('meth, 'inner_prefix, 'params, 'query, - 'input, 'output, 'error) service -> + 'input, 'output) service -> ('meth, 'prefix, 'params, - 'query, 'input, 'output, 'error) service + 'query, 'input, 'output) service val map: ('a -> 'b) -> ('b -> 'a) -> - ('meth, 'pr, 'a, 'q, 'i, 'o, 'e) service -> - ('meth, 'pr, 'b, 'q, 'i, 'o, 'e) service + ('meth, 'pr, 'a, 'q, 'i, 'o) service -> + ('meth, 'pr, 'b, 'q, 'i, 'o) service val get_service: ?description: string -> query: 'query RPC_query.t -> output: 'output Data_encoding.t -> - error: 'error Data_encoding.t -> ('prefix, 'params) RPC_path.t -> - ([ `GET ], 'prefix, 'params, 'query, unit, 'output, 'error) service + ([ `GET ], 'prefix, 'params, 'query, unit, 'output) service val post_service: ?description: string -> query:'query RPC_query.t -> input: 'input Data_encoding.t -> output: 'output Data_encoding.t -> - error: 'error Data_encoding.t -> ('prefix, 'params) RPC_path.t -> - ([ `POST ], 'prefix, 'params, 'query, 'input, 'output, 'error) service + ([ `POST ], 'prefix, 'params, 'query, 'input, 'output) service val delete_service: ?description: string -> query:'query RPC_query.t -> output: 'output Data_encoding.t -> - error: 'error Data_encoding.t -> ('prefix, 'params) RPC_path.t -> - ([ `DELETE ], 'prefix, 'params, 'query, unit, 'output, 'error) service + ([ `DELETE ], 'prefix, 'params, 'query, unit, 'output) service val patch_service: ?description: string -> query:'query RPC_query.t -> input: 'input Data_encoding.t -> output: 'output Data_encoding.t -> - error: 'error Data_encoding.t -> ('prefix, 'params) RPC_path.t -> - ([ `PATCH ], 'prefix, 'params, 'query, 'input, 'output, 'error) service + ([ `PATCH ], 'prefix, 'params, 'query, 'input, 'output) service val put_service: ?description: string -> query:'query RPC_query.t -> input: 'input Data_encoding.t -> output: 'output Data_encoding.t -> - error: 'error Data_encoding.t -> ('prefix, 'params) RPC_path.t -> - ([ `PUT ], 'prefix, 'params, 'query, 'input, 'output, 'error) service + ([ `PUT ], 'prefix, 'params, 'query, 'input, 'output) service diff --git a/src/lib_rpc/RPC_answer.ml b/src/lib_rpc/RPC_answer.ml index 9396a8d38..06380d84d 100644 --- a/src/lib_rpc/RPC_answer.ml +++ b/src/lib_rpc/RPC_answer.ml @@ -7,4 +7,23 @@ (* *) (**************************************************************************) -include Resto_directory.Answer +(** Return type for service handler *) +type 'o t = + [ `Ok of 'o (* 200 *) + | `OkStream of 'o stream (* 200 *) + | `Created of string option (* 201 *) + | `No_content (* 204 *) + | `Unauthorized of unit option (* 401 *) + | `Forbidden of unit option (* 403 *) + | `Not_found of unit option (* 404 *) + | `Conflict of unit option (* 409 *) + | `Error of unit option (* 500 *) + ] + +and 'a stream = 'a Resto_directory.Answer.stream = { + next: unit -> 'a option Lwt.t ; + shutdown: unit -> unit ; +} + +let return x = Lwt.return (`Ok x) +let return_stream x = Lwt.return (`OkStream x) diff --git a/src/lib_rpc/RPC_answer.mli b/src/lib_rpc/RPC_answer.mli index da6836da0..573cb47c9 100644 --- a/src/lib_rpc/RPC_answer.mli +++ b/src/lib_rpc/RPC_answer.mli @@ -7,4 +7,23 @@ (* *) (**************************************************************************) -include module type of (struct include Resto_directory.Answer end) +(** Return type for service handler *) +type 'o t = + [ `Ok of 'o (* 200 *) + | `OkStream of 'o stream (* 200 *) + | `Created of string option (* 201 *) + | `No_content (* 204 *) + | `Unauthorized of unit option (* 401 *) + | `Forbidden of unit option (* 403 *) + | `Not_found of unit option (* 404 *) + | `Conflict of unit option (* 409 *) + | `Error of unit option (* 500 *) + ] + +and 'a stream = 'a Resto_directory.Answer.stream = { + next: unit -> 'a option Lwt.t ; + shutdown: unit -> unit ; +} + +val return: 'o -> 'o t Lwt.t +val return_stream: 'o stream -> 'o t Lwt.t diff --git a/src/lib_rpc/RPC_directory.mli b/src/lib_rpc/RPC_directory.mli index e2fa5fe22..56521a316 100644 --- a/src/lib_rpc/RPC_directory.mli +++ b/src/lib_rpc/RPC_directory.mli @@ -8,3 +8,47 @@ (**************************************************************************) include module type of (struct include Resto_directory.Make(RPC_encoding) end) + +(** Registring handler in service tree. *) +val register: + 'prefix directory -> + ('meth, 'prefix, 'params, 'query, 'input, 'output) RPC_service.t -> + ('params -> 'query -> 'input -> [< 'output RPC_answer.t ] Lwt.t) -> + 'prefix directory + +(** Registring handler in service tree. Curryfied variant. *) +val register0: + unit directory -> + ('m, unit, unit, 'q, 'i, 'o) RPC_service.t -> + ('q -> 'i -> [< 'o RPC_answer.t ] Lwt.t) -> + unit directory + +val register1: + 'prefix directory -> + ('m, 'prefix, unit * 'a, 'q , 'i, 'o) RPC_service.t -> + ('a -> 'q -> 'i -> [< 'o RPC_answer.t ] Lwt.t) -> + 'prefix directory + +val register2: + 'prefix directory -> + ('m, 'prefix, (unit * 'a) * 'b, 'q , 'i, 'o) RPC_service.t -> + ('a -> 'b -> 'q -> 'i -> [< 'o RPC_answer.t ] Lwt.t) -> + 'prefix directory + +val register3: + 'prefix directory -> + ('m, 'prefix, ((unit * 'a) * 'b) * 'c, 'q , 'i, 'o) RPC_service.t -> + ('a -> 'b -> 'c -> 'q -> 'i -> [< 'o RPC_answer.t ] Lwt.t) -> + 'prefix directory + +val register4: + 'prefix directory -> + ('m, 'prefix, (((unit * 'a) * 'b) * 'c) * 'd, 'q , 'i, 'o) RPC_service.t -> + ('a -> 'b -> 'c -> 'd -> 'q -> 'i -> [< 'o RPC_answer.t ] Lwt.t) -> + 'prefix directory + +val register5: + 'prefix directory -> + ('m, 'prefix, ((((unit * 'a) * 'b) * 'c) * 'd) * 'e, 'q , 'i, 'o) RPC_service.t -> + ('a -> 'b -> 'c -> 'd -> 'e -> 'q -> 'i -> [< 'o RPC_answer.t ] Lwt.t) -> + 'prefix directory diff --git a/src/lib_rpc/RPC_error.ml b/src/lib_rpc/RPC_error.ml index 861bc6b3e..cc01dc8f6 100644 --- a/src/lib_rpc/RPC_error.ml +++ b/src/lib_rpc/RPC_error.ml @@ -13,7 +13,6 @@ let service = ~query: RPC_query.empty ~input: Data_encoding.empty ~output: Data_encoding.json_schema - ~error: Data_encoding.empty RPC_path.(root / "errors") let encoding = diff --git a/src/lib_rpc/RPC_error.mli b/src/lib_rpc/RPC_error.mli index 325d95a91..87d495d52 100644 --- a/src/lib_rpc/RPC_error.mli +++ b/src/lib_rpc/RPC_error.mli @@ -10,6 +10,6 @@ open Error_monad val service: - ([ `POST ], unit, unit, unit, unit, Json_schema.schema, unit) RPC_service.t + ([ `POST ], unit, unit, unit, unit, Json_schema.schema) RPC_service.t val encoding: error list Data_encoding.t val wrap: 'a Data_encoding.t -> 'a tzresult Data_encoding.encoding diff --git a/src/lib_rpc/RPC_service.ml b/src/lib_rpc/RPC_service.ml index 6da01974f..4a647689f 100644 --- a/src/lib_rpc/RPC_service.ml +++ b/src/lib_rpc/RPC_service.ml @@ -24,4 +24,26 @@ let meth_encoding = module MethMap = Resto.MethMap -include Resto.MakeService(RPC_encoding) +type (+'m,'pr,'p,'q,'i,'o, 'e) raw = + ('m,'pr,'p,'q,'i,'o, 'e) Resto.MakeService(RPC_encoding).t + constraint 'meth = [< meth ] + +type (+'meth, 'prefix, 'params, 'query, 'input, 'output) t = + ('meth, 'prefix, 'params, 'query, 'input, 'output, unit) raw + constraint 'meth = [< meth ] + +type (+'meth, 'prefix, 'params, 'query, 'input, 'output) service = + ('meth, 'prefix, 'params, 'query, 'input, 'output, unit) raw + constraint 'meth = [< meth ] + +include (Resto.MakeService(RPC_encoding) + : (module type of struct include Resto.MakeService(RPC_encoding) end + with type (+'m,'pr,'p,'q,'i,'o, 'e) t := ('m,'pr,'p,'q,'i,'o, 'e) raw + and type (+'m,'pr,'p,'q,'i,'o, 'e) service := ('m,'pr,'p,'q,'i,'o, 'e) raw) + ) + +let get_service = get_service ~error:Data_encoding.empty +let post_service = post_service ~error:Data_encoding.empty +let delete_service = delete_service ~error:Data_encoding.empty +let patch_service = patch_service ~error:Data_encoding.empty +let put_service = put_service ~error:Data_encoding.empty diff --git a/src/lib_rpc/RPC_service.mli b/src/lib_rpc/RPC_service.mli index 52cf54223..3f5007daf 100644 --- a/src/lib_rpc/RPC_service.mli +++ b/src/lib_rpc/RPC_service.mli @@ -15,4 +15,56 @@ val meth_encoding: meth Data_encoding.t module MethMap = Resto.MethMap -include (module type of struct include Resto.MakeService(RPC_encoding) end) +type (+'m,'pr,'p,'q,'i,'o, 'e) raw = + ('m,'pr,'p,'q,'i,'o, 'e) Resto.MakeService(RPC_encoding).t + constraint 'meth = [< meth ] + +type (+'meth, 'prefix, 'params, 'query, 'input, 'output) t = + ('meth, 'prefix, 'params, 'query, 'input, 'output, unit) raw + constraint 'meth = [< meth ] + +type (+'meth, 'prefix, 'params, 'query, 'input, 'output) service = + ('meth, 'prefix, 'params, 'query, 'input, 'output, unit) raw + constraint 'meth = [< meth ] + +include (module type of struct include Resto.MakeService(RPC_encoding) end + with type (+'m,'pr,'p,'q,'i,'o, 'e) t := ('m,'pr,'p,'q,'i,'o, 'e) raw + and type (+'m,'pr,'p,'q,'i,'o, 'e) service := ('m,'pr,'p,'q,'i,'o, 'e) raw) + +val get_service: + ?description: string -> + query: 'query RPC_query.t -> + output: 'output Data_encoding.t -> + ('prefix, 'params) RPC_path.t -> + ([ `GET ], 'prefix, 'params, 'query, unit, 'output) service + +val post_service: + ?description: string -> + query:'query RPC_query.t -> + input: 'input Data_encoding.t -> + output: 'output Data_encoding.t -> + ('prefix, 'params) RPC_path.t -> + ([ `POST ], 'prefix, 'params, 'query, 'input, 'output) service + +val delete_service: + ?description: string -> + query:'query RPC_query.t -> + output: 'output Data_encoding.t -> + ('prefix, 'params) RPC_path.t -> + ([ `DELETE ], 'prefix, 'params, 'query, unit, 'output) service + +val patch_service: + ?description: string -> + query:'query RPC_query.t -> + input: 'input Data_encoding.t -> + output: 'output Data_encoding.t -> + ('prefix, 'params) RPC_path.t -> + ([ `PATCH ], 'prefix, 'params, 'query, 'input, 'output) service + +val put_service: + ?description: string -> + query:'query RPC_query.t -> + input: 'input Data_encoding.t -> + output: 'output Data_encoding.t -> + ('prefix, 'params) RPC_path.t -> + ([ `PUT ], 'prefix, 'params, 'query, 'input, 'output) service diff --git a/src/lib_rpc_http/RPC_client.ml b/src/lib_rpc_http/RPC_client.ml index a292489f7..30ed545e2 100644 --- a/src/lib_rpc_http/RPC_client.ml +++ b/src/lib_rpc_http/RPC_client.ml @@ -381,7 +381,7 @@ let handle accept (meth, uri, ans) = let call_streamed_service (type p q i o ) - accept ?logger ~base (service : (_,_,p,q,i,o,_) RPC_service.t) + accept ?logger ~base (service : (_,_,p,q,i,o) RPC_service.t) ~on_chunk ~on_close (params : p) (query : q) (body : i) : (unit -> unit) tzresult Lwt.t = Client.call_streamed_service @@ -391,7 +391,7 @@ let call_streamed_service let call_service (type p q i o ) - accept ?logger ~base (service : (_,_,p,q,i,o,_) RPC_service.t) + accept ?logger ~base (service : (_,_,p,q,i,o) RPC_service.t) (params : p) (query : q) (body : i) : o tzresult Lwt.t = Client.call_service diff --git a/src/lib_rpc_http/RPC_client.mli b/src/lib_rpc_http/RPC_client.mli index 966056577..54edd611c 100644 --- a/src/lib_rpc_http/RPC_client.mli +++ b/src/lib_rpc_http/RPC_client.mli @@ -79,14 +79,14 @@ val call_service : Media_type.t list -> ?logger:logger -> base:Uri.t -> - ([< Resto.meth ], unit, 'p, 'q, 'i, 'o, 'e) RPC_service.t -> + ([< Resto.meth ], unit, 'p, 'q, 'i, 'o) RPC_service.t -> 'p -> 'q -> 'i -> 'o tzresult Lwt.t val call_streamed_service : Media_type.t list -> ?logger:logger -> base:Uri.t -> - ([< Resto.meth ], unit, 'p, 'q, 'i, 'o, 'e) RPC_service.t -> + ([< Resto.meth ], unit, 'p, 'q, 'i, 'o) RPC_service.t -> on_chunk: ('o -> unit) -> on_close: (unit -> unit) -> 'p -> 'q -> 'i -> (unit -> unit) tzresult Lwt.t diff --git a/src/lib_shell_services/block_services.ml b/src/lib_shell_services/block_services.ml index 77a1d9390..65f53c37f 100644 --- a/src/lib_shell_services/block_services.ml +++ b/src/lib_shell_services/block_services.ml @@ -116,7 +116,6 @@ let info = ~query: RPC_query.empty ~input: (obj1 (dft "operations" bool true)) ~output: block_info_encoding - ~error: Data_encoding.empty block_path let net_id = @@ -125,7 +124,6 @@ let net_id = ~query: RPC_query.empty ~input: empty ~output: (obj1 (req "net_id" Net_id.encoding)) - ~error: Data_encoding.empty RPC_path.(block_path / "net_id") let level = @@ -134,7 +132,6 @@ let level = ~query: RPC_query.empty ~input: empty ~output: (obj1 (req "level" int32)) - ~error: Data_encoding.empty RPC_path.(block_path / "level") let predecessor = @@ -143,7 +140,6 @@ let predecessor = ~query: RPC_query.empty ~input: empty ~output: (obj1 (req "predecessor" Block_hash.encoding)) - ~error: Data_encoding.empty RPC_path.(block_path / "predecessor") let predecessors = @@ -154,7 +150,6 @@ let predecessors = ~input: (obj1 (req "length" Data_encoding.uint16)) ~output: (obj1 (req "blocks" (Data_encoding.list Block_hash.encoding))) - ~error: Data_encoding.empty RPC_path.(block_path / "predecessors") let hash = @@ -163,7 +158,6 @@ let hash = ~query: RPC_query.empty ~input: empty ~output: (obj1 (req "hash" Block_hash.encoding)) - ~error: Data_encoding.empty RPC_path.(block_path / "hash") let fitness = @@ -172,7 +166,6 @@ let fitness = ~query: RPC_query.empty ~input: empty ~output: (obj1 (req "fitness" Fitness.encoding)) - ~error: Data_encoding.empty RPC_path.(block_path / "fitness") let context = @@ -181,7 +174,6 @@ let context = ~query: RPC_query.empty ~input: empty ~output: (obj1 (req "context" Context_hash.encoding)) - ~error: Data_encoding.empty RPC_path.(block_path / "context") let timestamp = @@ -190,7 +182,6 @@ let timestamp = ~query: RPC_query.empty ~input: empty ~output: (obj1 (req "timestamp" Time.encoding)) - ~error: Data_encoding.empty RPC_path.(block_path / "timestamp") type operations_param = { @@ -219,7 +210,6 @@ let operations = (req "hash" Operation_hash.encoding) (opt "contents" (dynamic_size Operation.encoding))))))) - ~error: Data_encoding.empty RPC_path.(block_path / "operations") let protocol = @@ -228,7 +218,6 @@ let protocol = ~query: RPC_query.empty ~input: empty ~output: (obj1 (req "protocol" Protocol_hash.encoding)) - ~error: Data_encoding.empty RPC_path.(block_path / "protocol") let test_network = @@ -237,7 +226,6 @@ let test_network = ~query: RPC_query.empty ~input: empty ~output: Test_network_status.encoding - ~error: Data_encoding.empty RPC_path.(block_path / "test_network") let pending_operations = @@ -266,7 +254,6 @@ let pending_operations = (dynamic_size (Preapply_result.encoding RPC_error.encoding)) (obj1 (req "unprocessed" (list (dynamic_size operation_encoding)))))) - ~error: Data_encoding.empty RPC_path.(block_path / "pending_operations") let proto_path = @@ -315,7 +302,6 @@ let preapply = ~query: RPC_query.empty ~input: preapply_param_encoding ~output: (RPC_error.wrap preapply_result_encoding) - ~error: Data_encoding.empty RPC_path.(block_path / "preapply") let complete = @@ -330,7 +316,6 @@ let complete = ~query: RPC_query.empty ~input: empty ~output: (list string) - ~error: Data_encoding.empty RPC_path.(block_path / "complete" /: prefix_arg ) type list_param = { @@ -407,7 +392,6 @@ let list = ~query: RPC_query.empty ~input: list_param_encoding ~output: (obj1 (req "blocks" (list (list block_info_encoding)))) - ~error: Data_encoding.empty RPC_path.(root / "blocks") let list_invalid = @@ -422,7 +406,6 @@ let list_invalid = (req "block" Block_hash.encoding) (req "level" int32) (req "errors" RPC_error.encoding))) - ~error: Data_encoding.empty RPC_path.(root / "invalid_blocks") let unmark_invalid = @@ -432,5 +415,4 @@ let unmark_invalid = ~query: RPC_query.empty ~input:Data_encoding.(obj1 (req "block" Block_hash.encoding)) ~output:(RPC_error.wrap Data_encoding.empty) - ~error: Data_encoding.empty RPC_path.(root / "unmark_invalid") diff --git a/src/lib_shell_services/block_services.mli b/src/lib_shell_services/block_services.mli index 38db7a70c..970e95917 100644 --- a/src/lib_shell_services/block_services.mli +++ b/src/lib_shell_services/block_services.mli @@ -38,39 +38,39 @@ type block_info = { val info: ([ `POST ], unit, unit * block, unit, bool, - block_info, unit) RPC_service.t + block_info) RPC_service.t val net_id: ([ `POST ], unit, unit * block, unit, unit, - Net_id.t, unit) RPC_service.t + Net_id.t) RPC_service.t val level: ([ `POST ], unit, unit * block, unit, unit, - Int32.t, unit) RPC_service.t + Int32.t) RPC_service.t val predecessor: ([ `POST ], unit, unit * block, unit, unit, - Block_hash.t, unit) RPC_service.t + Block_hash.t) RPC_service.t val predecessors: ([ `POST ], unit, unit * block , unit, int, - Block_hash.t list, unit) RPC_service.t + Block_hash.t list) RPC_service.t val hash: ([ `POST ], unit, unit * block, unit, unit, - Block_hash.t, unit) RPC_service.t + Block_hash.t) RPC_service.t val timestamp: ([ `POST ], unit, unit * block, unit, unit, - Time.t, unit) RPC_service.t + Time.t) RPC_service.t val fitness: ([ `POST ], unit, unit * block, unit, unit, - MBytes.t list, unit) RPC_service.t + MBytes.t list) RPC_service.t val context: ([ `POST ], unit, unit * block, unit, unit, - Context_hash.t, unit) RPC_service.t + Context_hash.t) RPC_service.t type operations_param = { contents: bool ; @@ -79,20 +79,20 @@ type operations_param = { val operations: ([ `POST ], unit, unit * block, unit, operations_param, - (Operation_hash.t * Operation.t option) list list, unit) RPC_service.t + (Operation_hash.t * Operation.t option) list list) RPC_service.t val protocol: ([ `POST ], unit, unit * block, unit, unit, - Protocol_hash.t, unit) RPC_service.t + Protocol_hash.t) RPC_service.t val test_network: ([ `POST ], unit, unit * block, unit, unit, - Test_network_status.t, unit) RPC_service.t + Test_network_status.t) RPC_service.t val pending_operations: ([ `POST ], unit, unit * block, unit, unit, - error Preapply_result.t * Operation.t Operation_hash.Map.t, unit) RPC_service.t + error Preapply_result.t * Operation.t Operation_hash.Map.t) RPC_service.t type list_param = { include_ops: bool ; @@ -106,15 +106,15 @@ type list_param = { val list: ([ `POST ], unit, unit, unit, list_param, - block_info list list, unit) RPC_service.t + block_info list list) RPC_service.t val list_invalid: ([ `POST ], unit, unit, unit, unit, - (Block_hash.t * int32 * error list) list, unit) RPC_service.t + (Block_hash.t * int32 * error list) list) RPC_service.t val unmark_invalid: - ([ `POST ], unit, unit, unit, Block_hash.t, unit tzresult, unit) RPC_service.t + ([ `POST ], unit, unit, unit, Block_hash.t, unit tzresult) RPC_service.t type preapply_param = { timestamp: Time.t ; @@ -130,11 +130,11 @@ type preapply_result = { val preapply: ([ `POST ], unit, unit * block, unit, preapply_param, - preapply_result tzresult, unit) RPC_service.t + preapply_result tzresult) RPC_service.t val complete: ([ `POST ], unit, (unit * block) * string, unit, unit, - string list, unit) RPC_service.t + string list) RPC_service.t val proto_path: (unit, unit * block) RPC_path.path diff --git a/src/lib_shell_services/p2p_services.ml b/src/lib_shell_services/p2p_services.ml index 549dd7605..009079ede 100644 --- a/src/lib_shell_services/p2p_services.ml +++ b/src/lib_shell_services/p2p_services.ml @@ -21,7 +21,6 @@ let versions = ~query: RPC_query.empty ~input: Data_encoding.empty ~output: (Data_encoding.list P2p_version.encoding) - ~error: Data_encoding.empty RPC_path.(root / "network" / "versions") let stat = @@ -30,7 +29,6 @@ let stat = ~query: RPC_query.empty ~input: Data_encoding.empty ~output: P2p_stat.encoding - ~error: Data_encoding.empty RPC_path.(root / "network" / "stat") let events = @@ -39,7 +37,6 @@ let events = ~query: RPC_query.empty ~input: Data_encoding.empty ~output: P2p_connection.Pool_event.encoding - ~error: Data_encoding.empty RPC_path.(root / "network" / "log") let connect = @@ -48,7 +45,6 @@ let connect = ~query: RPC_query.empty ~input: Data_encoding.(obj1 (dft "timeout" float 5.)) ~output: (RPC_error.wrap Data_encoding.empty) - ~error: Data_encoding.empty RPC_path.(root / "network" / "connect" /: point_arg) let monitor_encoding = Data_encoding.(obj1 (dft "monitor" bool false)) @@ -61,7 +57,6 @@ module Connection = struct ~query: RPC_query.empty ~input: Data_encoding.empty ~output: (Data_encoding.list P2p_connection.Info.encoding) - ~error: Data_encoding.empty RPC_path.(root / "network" / "connection") let info = @@ -69,7 +64,6 @@ module Connection = struct ~query: RPC_query.empty ~input: Data_encoding.empty ~output: (Data_encoding.option P2p_connection.Info.encoding) - ~error: Data_encoding.empty ~description:"Details about the current P2P connection to the given peer." RPC_path.(root / "network" / "connection" /: P2p_peer.Id.rpc_arg) @@ -78,7 +72,6 @@ module Connection = struct ~query: RPC_query.empty ~input: Data_encoding.(obj1 (req "wait" bool)) ~output: Data_encoding.empty - ~error: Data_encoding.empty ~description:"Forced close of the current P2P connection to the given peer." RPC_path.(root / "network" / "connection" /: P2p_peer.Id.rpc_arg / "kick") @@ -91,7 +84,6 @@ module Point = struct ~query: RPC_query.empty ~input: Data_encoding.empty ~output: (Data_encoding.option P2p_point.Info.encoding) - ~error: Data_encoding.empty ~description: "Details about a given `IP:addr`." RPC_path.(root / "network" / "point" /: point_arg) @@ -101,7 +93,6 @@ module Point = struct ~input: monitor_encoding ~output: (Data_encoding.list P2p_point.Pool_event.encoding) - ~error: Data_encoding.empty ~description: "Monitor network events related to an `IP:addr`." RPC_path.(root / "network" / "point" /: point_arg / "log") @@ -116,7 +107,6 @@ module Point = struct Data_encoding.(list (tup2 P2p_point.Id.encoding P2p_point.Info.encoding)) - ~error: Data_encoding.empty ~description:"List the pool of known `IP:port` \ used for establishing P2P connections ." RPC_path.(root / "network" / "point") @@ -130,7 +120,6 @@ module Peer_id = struct ~query: RPC_query.empty ~input: Data_encoding.empty ~output: (Data_encoding.option P2p_peer.Info.encoding) - ~error: Data_encoding.empty ~description:"Details about a given peer." RPC_path.(root / "network" / "peer_id" /: P2p_peer.Id.rpc_arg) @@ -140,7 +129,6 @@ module Peer_id = struct ~input: monitor_encoding ~output: (Data_encoding.list P2p_peer.Pool_event.encoding) - ~error: Data_encoding.empty ~description:"Monitor network events related to a given peer." RPC_path.(root / "network" / "peer_id" /: P2p_peer.Id.rpc_arg / "log") @@ -155,7 +143,6 @@ module Peer_id = struct Data_encoding.(list (tup2 P2p_peer.Id.encoding P2p_peer.Info.encoding)) - ~error: Data_encoding.empty ~description:"List the peers the node ever met." RPC_path.(root / "network" / "peer_id") diff --git a/src/lib_shell_services/p2p_services.mli b/src/lib_shell_services/p2p_services.mli index b96eb611d..3a205e34d 100644 --- a/src/lib_shell_services/p2p_services.mli +++ b/src/lib_shell_services/p2p_services.mli @@ -10,39 +10,39 @@ val stat : ([ `POST ], unit, unit, unit, unit, - P2p_stat.t, unit) RPC_service.t + P2p_stat.t) RPC_service.t val versions : ([ `POST ], unit, unit, unit, unit, - P2p_version.t list, unit) RPC_service.t + P2p_version.t list) RPC_service.t val events : ([ `POST ], unit, unit, unit, unit, - P2p_connection.Pool_event.t, unit) RPC_service.t + P2p_connection.Pool_event.t) RPC_service.t val connect : ([ `POST ], unit, unit * P2p_point.Id.t, unit, float, - unit tzresult, unit) RPC_service.t + unit tzresult) RPC_service.t module Connection : sig val list : ([ `POST ], unit, unit, unit, unit, - P2p_connection.Info.t list, unit) RPC_service.t + P2p_connection.Info.t list) RPC_service.t val info : ([ `POST ], unit, unit * P2p_peer.Id.t, unit, unit, - P2p_connection.Info.t option, unit) RPC_service.t + P2p_connection.Info.t option) RPC_service.t val kick : ([ `POST ], unit, unit * P2p_peer.Id.t, unit, bool, - unit, unit) RPC_service.t + unit) RPC_service.t end @@ -50,15 +50,15 @@ module Point : sig val list : ([ `POST ], unit, unit, unit, P2p_point.State.t list, - (P2p_point.Id.t * P2p_point.Info.t) list, unit) RPC_service.t + (P2p_point.Id.t * P2p_point.Info.t) list) RPC_service.t val info : ([ `POST ], unit, unit * P2p_point.Id.t, unit, unit, - P2p_point.Info.t option, unit) RPC_service.t + P2p_point.Info.t option) RPC_service.t val events : ([ `POST ], unit, unit * P2p_point.Id.t, unit, bool, - P2p_point.Pool_event.t list, unit) RPC_service.t + P2p_point.Pool_event.t list) RPC_service.t end module Peer_id : sig @@ -66,16 +66,16 @@ module Peer_id : sig val list : ([ `POST ], unit, unit, unit, P2p_peer.State.t list, - (P2p_peer.Id.t * P2p_peer.Info.t) list, unit) RPC_service.t + (P2p_peer.Id.t * P2p_peer.Info.t) list) RPC_service.t val info : ([ `POST ], unit, unit * P2p_peer.Id.t, unit, unit, - P2p_peer.Info.t option, unit) RPC_service.t + P2p_peer.Info.t option) RPC_service.t val events : ([ `POST ], unit, unit * P2p_peer.Id.t, unit, bool, - P2p_peer.Pool_event.t list, unit) RPC_service.t + P2p_peer.Pool_event.t list) RPC_service.t end diff --git a/src/lib_shell_services/protocol_services.ml b/src/lib_shell_services/protocol_services.ml index 156b6a96d..28b9799ab 100644 --- a/src/lib_shell_services/protocol_services.ml +++ b/src/lib_shell_services/protocol_services.ml @@ -19,7 +19,6 @@ let contents = (obj1 (req "data" (describe ~title: "Tezos protocol" (Protocol.encoding)))) - ~error: Data_encoding.empty RPC_path.(root / "protocols" /: protocols_arg) type list_param = { @@ -48,5 +47,4 @@ let list = (opt "contents" (dynamic_size Protocol.encoding))) ))) - ~error: Data_encoding.empty RPC_path.(root / "protocols") diff --git a/src/lib_shell_services/protocol_services.mli b/src/lib_shell_services/protocol_services.mli index 8b5d8ff27..7682b24f4 100644 --- a/src/lib_shell_services/protocol_services.mli +++ b/src/lib_shell_services/protocol_services.mli @@ -10,7 +10,7 @@ val contents: ([ `POST ], unit, unit * Protocol_hash.t, unit, unit, - Protocol.t, unit) RPC_service.t + Protocol.t) RPC_service.t type list_param = { contents: bool option ; @@ -20,4 +20,4 @@ type list_param = { val list: ([ `POST ], unit, unit, unit, list_param, - (Protocol_hash.t * Protocol.t option) list, unit) RPC_service.t + (Protocol_hash.t * Protocol.t option) list) RPC_service.t diff --git a/src/lib_shell_services/shell_services.ml b/src/lib_shell_services/shell_services.ml index a1554b7c6..b31a4b61b 100644 --- a/src/lib_shell_services/shell_services.ml +++ b/src/lib_shell_services/shell_services.ml @@ -15,7 +15,6 @@ let forge_block_header = ~query: RPC_query.empty ~input: Block_header.encoding ~output: (obj1 (req "block" bytes)) - ~error: Data_encoding.empty RPC_path.(root / "forge_block_header") type inject_block_param = { @@ -68,7 +67,6 @@ let inject_block = ~output: (RPC_error.wrap @@ (obj1 (req "block_hash" Block_hash.encoding))) - ~error: Data_encoding.empty RPC_path.(root / "inject_block") let inject_operation = @@ -100,7 +98,6 @@ let inject_operation = describe ~title: "Hash of the injected operation" @@ (obj1 (req "injectedOperation" Operation_hash.encoding))) - ~error: Data_encoding.empty RPC_path.(root / "inject_operation") let inject_protocol = @@ -129,7 +126,6 @@ let inject_protocol = describe ~title: "Hash of the injected protocol" @@ (obj1 (req "injectedProtocol" Protocol_hash.encoding))) - ~error: Data_encoding.empty RPC_path.(root / "inject_protocol") let bootstrapped = @@ -140,7 +136,6 @@ let bootstrapped = ~output: (obj2 (req "block" Block_hash.encoding) (req "timestamp" Time.encoding)) - ~error: Data_encoding.empty RPC_path.(root / "bootstrapped") let complete = @@ -155,7 +150,6 @@ let complete = ~query: RPC_query.empty ~input: empty ~output: (list string) - ~error: Data_encoding.empty RPC_path.(root / "complete" /: prefix_arg ) let describe = diff --git a/src/lib_shell_services/shell_services.mli b/src/lib_shell_services/shell_services.mli index b2ae04021..32d3b2ba4 100644 --- a/src/lib_shell_services/shell_services.mli +++ b/src/lib_shell_services/shell_services.mli @@ -10,7 +10,7 @@ val forge_block_header: ([ `POST ], unit, unit, unit, Block_header.t, - MBytes.t, unit) RPC_service.t + MBytes.t) RPC_service.t type inject_block_param = { raw: MBytes.t ; @@ -23,26 +23,26 @@ type inject_block_param = { val inject_block: ([ `POST ], unit, unit, unit, inject_block_param, - Block_hash.t tzresult, unit) RPC_service.t + Block_hash.t tzresult) RPC_service.t val inject_operation: ([ `POST ], unit, unit, unit, (MBytes.t * bool * Net_id.t option), - Operation_hash.t tzresult, unit) RPC_service.t + Operation_hash.t tzresult) RPC_service.t val inject_protocol: ([ `POST ], unit, unit, unit, (Protocol.t * bool * bool option), - Protocol_hash.t tzresult, unit) RPC_service.t + Protocol_hash.t tzresult) RPC_service.t val bootstrapped: ([ `POST ], unit, unit, unit, unit, - Block_hash.t * Time.t, unit) RPC_service.t + Block_hash.t * Time.t) RPC_service.t val complete: ([ `POST ], unit, unit * string, unit, unit, - string list, unit) RPC_service.t + string list) RPC_service.t val describe: (unit, unit) RPC_service.description_service diff --git a/src/lib_shell_services/worker_services.ml b/src/lib_shell_services/worker_services.ml index 4fdcf22c2..fb611b29c 100644 --- a/src/lib_shell_services/worker_services.ml +++ b/src/lib_shell_services/worker_services.ml @@ -25,7 +25,6 @@ module Prevalidators = struct RPC_service.post_service ~description:"Lists the Prevalidator workers and their status." ~query: RPC_query.empty - ~error: Data_encoding.empty ~input: empty ~output: (list @@ -39,7 +38,6 @@ module Prevalidators = struct RPC_service.post_service ~description:"Introspect the state of a prevalidator worker." ~query: RPC_query.empty - ~error: Data_encoding.empty ~input: empty ~output: (Worker_types.full_status_encoding @@ -57,7 +55,6 @@ module Block_validator = struct RPC_service.post_service ~description:"Introspect the state of the block_validator worker." ~query: RPC_query.empty - ~error: Data_encoding.empty ~input: empty ~output: (Worker_types.full_status_encoding @@ -94,7 +91,6 @@ module Peer_validators = struct RPC_service.post_service ~description:"Lists the peer validator workers and their status." ~query: RPC_query.empty - ~error: Data_encoding.empty ~input: empty ~output: (list @@ -108,7 +104,6 @@ module Peer_validators = struct RPC_service.post_service ~description:"Introspect the state of a peer validator worker." ~query: RPC_query.empty - ~error: Data_encoding.empty ~input: empty ~output: (Worker_types.full_status_encoding @@ -135,7 +130,6 @@ module Net_validators = struct RPC_service.post_service ~description:"Lists the net validator workers and their status." ~query: RPC_query.empty - ~error: Data_encoding.empty ~input: empty ~output: (list @@ -149,7 +143,6 @@ module Net_validators = struct RPC_service.post_service ~description:"Introspect the state of a net validator worker." ~query: RPC_query.empty - ~error: Data_encoding.empty ~input: empty ~output: (Worker_types.full_status_encoding diff --git a/src/lib_shell_services/worker_services.mli b/src/lib_shell_services/worker_services.mli index a0225ca26..b479dddeb 100644 --- a/src/lib_shell_services/worker_services.mli +++ b/src/lib_shell_services/worker_services.mli @@ -14,13 +14,12 @@ module Prevalidators : sig val list : ([ `POST ], unit, unit, unit, unit, - (Net_id.t * Worker_types.worker_status) list, unit) RPC_service.t + (Net_id.t * Worker_types.worker_status) list) RPC_service.t val state : ([ `POST ], unit, unit * Net_id.t, unit, unit, - (Request.view, Event.t) Worker_types.full_status, unit) - RPC_service.t + (Request.view, Event.t) Worker_types.full_status) RPC_service.t end @@ -31,8 +30,7 @@ module Block_validator : sig val state : ([ `POST ], unit, unit, unit, unit, - (Request.view, Event.t) Worker_types.full_status, unit) - RPC_service.t + (Request.view, Event.t) Worker_types.full_status) RPC_service.t end @@ -43,13 +41,12 @@ module Peer_validators : sig val list : ([ `POST ], unit, unit * Net_id.t, unit, unit, - (P2p_peer.Id.t * Worker_types.worker_status) list, unit) RPC_service.t + (P2p_peer.Id.t * Worker_types.worker_status) list) RPC_service.t val state : ([ `POST ], unit, (unit * Net_id.t) * P2p_peer.Id.t, unit, unit, - (Request.view, Event.t) Worker_types.full_status, unit) - RPC_service.t + (Request.view, Event.t) Worker_types.full_status) RPC_service.t end @@ -60,12 +57,11 @@ module Net_validators : sig val list : ([ `POST ], unit, unit, unit, unit, - (Net_id.t * Worker_types.worker_status) list, unit) RPC_service.t + (Net_id.t * Worker_types.worker_status) list) RPC_service.t val state : ([ `POST ], unit, unit * Net_id.t, unit, unit, - (Request.view, Event.t) Worker_types.full_status, unit) - RPC_service.t + (Request.view, Event.t) Worker_types.full_status) RPC_service.t end diff --git a/src/proto_alpha/lib_protocol/src/services.ml b/src/proto_alpha/lib_protocol/src/services.ml index 5f003e76b..1c5ae8d83 100644 --- a/src/proto_alpha/lib_protocol/src/services.ml +++ b/src/proto_alpha/lib_protocol/src/services.ml @@ -42,7 +42,6 @@ let operations custom_root = ~input: empty ~output: (wrap_tzerror @@ (list (list (dynamic_size Operation.encoding)))) - ~error: Data_encoding.empty RPC_path.(custom_root / "operations") let header custom_root = @@ -51,7 +50,6 @@ let header custom_root = ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror Block_header.encoding) - ~error: Data_encoding.empty RPC_path.(custom_root / "header") module Header = struct @@ -62,7 +60,6 @@ module Header = struct ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror uint16) - ~error: Data_encoding.empty RPC_path.(custom_root / "header" / "priority") let seed_nonce_hash custom_root = @@ -71,7 +68,6 @@ module Header = struct ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror Nonce_hash.encoding) - ~error: Data_encoding.empty RPC_path.(custom_root / "header" / "seed_nonce_hash") end @@ -85,7 +81,6 @@ module Constants = struct ~input: empty ~output: (wrap_tzerror @@ describe ~title: "cycle length" int32) - ~error: Data_encoding.empty RPC_path.(custom_root / "constants" / "cycle_length") let voting_period_length custom_root = @@ -95,7 +90,6 @@ module Constants = struct ~input: empty ~output: (wrap_tzerror @@ describe ~title: "voting period length" int32) - ~error: Data_encoding.empty RPC_path.(custom_root / "constants" / "voting_period_length") let time_before_reward custom_root = @@ -105,7 +99,6 @@ module Constants = struct ~input: empty ~output: (wrap_tzerror @@ describe ~title: "time before reward" Period.encoding) - ~error: Data_encoding.empty RPC_path.(custom_root / "constants" / "time_before_reward") let slot_durations custom_root = @@ -115,7 +108,6 @@ module Constants = struct ~input: empty ~output: (wrap_tzerror @@ describe ~title: "time between slots" (list Period.encoding)) - ~error: Data_encoding.empty RPC_path.(custom_root / "constants" / "time_between_slots") let first_free_baking_slot custom_root = @@ -125,7 +117,6 @@ module Constants = struct ~input: empty ~output: (wrap_tzerror @@ describe ~title: "first free baking slot" uint16) - ~error: Data_encoding.empty RPC_path.(custom_root / "constants" / "first_free_baking_slot") let max_signing_slot custom_root = @@ -135,7 +126,6 @@ module Constants = struct ~input: empty ~output: (wrap_tzerror @@ describe ~title: "max signing slot" uint16) - ~error: Data_encoding.empty RPC_path.(custom_root / "constants" / "max_signing_slot") let max_gas custom_root = @@ -145,7 +135,6 @@ module Constants = struct ~input: empty ~output: (wrap_tzerror @@ describe ~title: "instructions per transaction" int31) - ~error: Data_encoding.empty RPC_path.(custom_root / "constants" / "max_gas") let proof_of_work_threshold custom_root = @@ -155,7 +144,6 @@ module Constants = struct ~input: empty ~output: (wrap_tzerror @@ describe ~title: "proof_of_work threshold" int64) - ~error: Data_encoding.empty RPC_path.(custom_root / "constants" / "proof_of_work_threshold") let errors custom_root = @@ -164,7 +152,6 @@ module Constants = struct ~query: RPC_query.empty ~input: empty ~output: json_schema - ~error: Data_encoding.empty RPC_path.(custom_root / "constants" / "errors") end @@ -178,7 +165,6 @@ module Context = struct ~input: empty ~output: (wrap_tzerror @@ describe ~title: "detailled level info" Level.encoding) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "level") let next_level custom_root = @@ -188,7 +174,6 @@ module Context = struct ~input: empty ~output: (wrap_tzerror @@ describe ~title: "detailled level info" Level.encoding) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "next_level") let roll_value custom_root = @@ -196,7 +181,6 @@ module Context = struct ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror Tez.encoding) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "roll_value") let next_roll custom_root = @@ -204,7 +188,6 @@ module Context = struct ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror int32) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "next_roll") let voting_period_kind custom_root = @@ -216,7 +199,6 @@ module Context = struct (wrap_tzerror @@ (obj1 (req "voting_period_kind" Voting_period.kind_encoding))) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "voting_period_kind") @@ -249,7 +231,6 @@ module Context = struct ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror nonce_encoding) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "nonce" /: Raw_level.arg) let hash custom_root = @@ -259,7 +240,6 @@ module Context = struct ~input: empty ~output: (wrap_tzerror @@ describe ~title: "nonce hash" Nonce_hash.encoding) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "nonce") end @@ -279,7 +259,6 @@ module Context = struct ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror @@ list pk_encoding) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "keys") let get custom_root = @@ -288,7 +267,6 @@ module Context = struct ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror @@ pk_encoding) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "keys" /: public_key_hash_arg ) end @@ -303,7 +281,6 @@ module Context = struct ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror Tez.encoding) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "contracts" /: Contract.arg / "balance") let manager custom_root = @@ -312,7 +289,6 @@ module Context = struct ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror Ed25519.Public_key_hash.encoding) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "contracts" /: Contract.arg / "manager") let delegate custom_root = @@ -321,7 +297,6 @@ module Context = struct ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror (option Ed25519.Public_key_hash.encoding)) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "contracts" /: Contract.arg / "delegate") let counter custom_root = @@ -330,7 +305,6 @@ module Context = struct ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror int32) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "contracts" /: Contract.arg / "counter") let spendable custom_root = @@ -339,7 +313,6 @@ module Context = struct ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror bool) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "contracts" /: Contract.arg / "spendable") let delegatable custom_root = @@ -348,7 +321,6 @@ module Context = struct ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror bool) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "contracts" /: Contract.arg / "delegatable") let script custom_root = @@ -357,7 +329,6 @@ module Context = struct ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror (option Script.encoding)) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "contracts" /: Contract.arg / "script") let storage custom_root = @@ -366,7 +337,6 @@ module Context = struct ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror (option Script.expr_encoding)) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "contracts" /: Contract.arg / "storage") type info = { @@ -399,7 +369,6 @@ module Context = struct (opt "value" Ed25519.Public_key_hash.encoding)) (opt "script" Script.encoding) (req "counter" int32)) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "contracts" /: Contract.arg) let list custom_root = @@ -409,7 +378,6 @@ module Context = struct ~query: RPC_query.empty ~input: empty ~output: (wrap_tzerror @@ list Contract.encoding) - ~error: Data_encoding.empty RPC_path.(custom_root / "context" / "contracts") end @@ -427,7 +395,6 @@ module Helpers = struct ~input: (obj1 (opt "priority" int31)) ~output: (wrap_tzerror @@ obj1 (req "timestamp" Timestamp.encoding)) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "minimal_timestamp") let run_code_input_encoding = @@ -449,7 +416,6 @@ module Helpers = struct (req "storage" Script.expr_encoding) (req "output" Script.expr_encoding) (opt "big_map_diff" (list (tup2 Script.expr_encoding (option Script.expr_encoding)))))) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "run_code") let apply_operation custom_root = @@ -463,7 +429,6 @@ module Helpers = struct (opt "signature" Ed25519.Signature.encoding)) ~output: (wrap_tzerror (obj1 (req "contracts" (list Contract.encoding)))) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "apply_operation") @@ -483,7 +448,6 @@ module Helpers = struct (req "gas" Gas.encoding) (req "stack" (list (Script.expr_encoding))))) (opt "big_map_diff" (list (tup2 Script.expr_encoding (option Script.expr_encoding)))))) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "trace_code") let typecheck_code custom_root = @@ -492,7 +456,6 @@ module Helpers = struct ~query: RPC_query.empty ~input: Script.expr_encoding ~output: (wrap_tzerror Script_tc_errors_registration.type_map_enc) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "typecheck_code") let typecheck_data custom_root = @@ -504,7 +467,6 @@ module Helpers = struct (req "data" Script.expr_encoding) (req "type" Script.expr_encoding)) ~output: (wrap_tzerror empty) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "typecheck_data") let hash_data custom_root = @@ -515,7 +477,6 @@ module Helpers = struct (req "type" Script.expr_encoding)) ~output: (wrap_tzerror @@ obj1 (req "hash" string)) - ~error: Data_encoding.empty ~query: RPC_query.empty RPC_path.(custom_root / "helpers" / "hash_data") @@ -527,7 +488,6 @@ module Helpers = struct (opt "offset" int32)) ~output: (wrap_tzerror @@ describe ~title: "block level and cycle information" Level.encoding) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "level" /: Raw_level.arg) let levels custom_root = @@ -540,7 +500,6 @@ module Helpers = struct (obj2 (req "first" Raw_level.encoding) (req "last" Raw_level.encoding))) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "levels" /: Cycle.arg) module Rights = struct @@ -577,7 +536,6 @@ module Helpers = struct (obj2 (req "delegate" Ed25519.Public_key_hash.encoding) (req "timestamp" Timestamp.encoding))))) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "rights" / "baking") let baking_rights_for_level custom_root = @@ -592,7 +550,6 @@ module Helpers = struct (req "level" Raw_level.encoding) (req "delegates" (list Ed25519.Public_key_hash.encoding))) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "rights" / "baking" / "level" /: Raw_level.arg ) @@ -604,7 +561,6 @@ module Helpers = struct ~input: empty ~output: (wrap_tzerror @@ obj1 (req "levels" (list Raw_level.encoding))) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "rights" / "baking" / "level" ) @@ -614,7 +570,6 @@ module Helpers = struct ~query: RPC_query.empty ~input: slots_range_encoding ~output: (wrap_tzerror (Data_encoding.list baking_slot_encoding)) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "rights" / "baking" / "delegate" /: Context.Key.public_key_hash_arg ) @@ -627,7 +582,6 @@ module Helpers = struct ~output: (wrap_tzerror @@ obj1 (req "delegates" (list Ed25519.Public_key_hash.encoding))) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "rights" / "baking" / "delegate" ) @@ -642,7 +596,6 @@ module Helpers = struct (req "level" Raw_level.encoding) (req "delegates" (list Ed25519.Public_key_hash.encoding))) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "rights" / "endorsement") let endorsement_rights_for_level custom_root = @@ -656,7 +609,6 @@ module Helpers = struct (req "level" Raw_level.encoding) (req "delegates" (list Ed25519.Public_key_hash.encoding))) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "rights" / "endorsement" / "level" /: Raw_level.arg ) @@ -668,7 +620,6 @@ module Helpers = struct ~input: empty ~output: (wrap_tzerror @@ obj1 (req "levels" (list Raw_level.encoding))) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "rights" / "endorsement" / "level" ) @@ -678,7 +629,6 @@ module Helpers = struct ~query: RPC_query.empty ~input: slots_range_encoding ~output: (wrap_tzerror @@ Data_encoding.list endorsement_slot_encoding) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "rights" / "endorsement" / "delegate" /: Context.Key.public_key_hash_arg ) @@ -691,7 +641,6 @@ module Helpers = struct ~output: (wrap_tzerror @@ obj1 (req "delegates" (list Ed25519.Public_key_hash.encoding))) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "rights" / "endorsement" / "delegate" ) @@ -709,7 +658,6 @@ module Helpers = struct (obj1 (req "operation" @@ describe ~title: "hex encoded operation" bytes))) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "forge" / "operations" ) let empty_proof_of_work_nonce = @@ -729,7 +677,6 @@ module Helpers = struct Tezos_context.Constants.proof_of_work_nonce_size) empty_proof_of_work_nonce)) ~output: (wrap_tzerror bytes) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "forge" / "block_proto_header") end @@ -746,7 +693,6 @@ module Helpers = struct (opt "check_signature" bool)) ~output: (wrap_tzerror (list (dynamic_size Operation.encoding))) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "parse" / "operations" ) let block custom_root = @@ -755,7 +701,6 @@ module Helpers = struct ~query: RPC_query.empty ~input: Block_header.raw_encoding ~output: (wrap_tzerror Block_header.proto_header_encoding) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "parse" / "block" ) end diff --git a/src/proto_demo/lib_protocol/src/services.ml b/src/proto_demo/lib_protocol/src/services.ml index 63f4ce9dc..9205450e1 100644 --- a/src/proto_demo/lib_protocol/src/services.ml +++ b/src/proto_demo/lib_protocol/src/services.ml @@ -37,7 +37,6 @@ let echo_service custom_root = ~query: RPC_query.empty ~input: Data_encoding.(obj1 (req "msg" string)) ~output: Data_encoding.(obj1 (req "msg" string)) - ~error: Data_encoding.empty RPC_path.(custom_root / "echo") let failing_service custom_root = @@ -46,7 +45,6 @@ let failing_service custom_root = ~query: RPC_query.empty ~input: Data_encoding.(obj1 (req "arg" int31)) ~output: (wrap_tzerror Data_encoding.empty) - ~error: Data_encoding.empty RPC_path.(custom_root / "failing") let rpc_services : Updater.rpc_context RPC_directory.t = let dir = RPC_directory.empty in diff --git a/src/proto_genesis/lib_protocol/src/services.ml b/src/proto_genesis/lib_protocol/src/services.ml index 9f52858eb..42920001b 100644 --- a/src/proto_genesis/lib_protocol/src/services.ml +++ b/src/proto_genesis/lib_protocol/src/services.ml @@ -48,7 +48,6 @@ module Forge = struct (req "context" Context_hash.encoding)) Data.Command.encoding) ~output: (obj1 (req "payload" bytes)) - ~error: Data_encoding.empty RPC_path.(custom_root / "helpers" / "forge" / "block") end diff --git a/vendors/ocplib-resto/lib_resto-directory/resto_directory.mli b/vendors/ocplib-resto/lib_resto-directory/resto_directory.mli index d31f3d64c..fd558521a 100644 --- a/vendors/ocplib-resto/lib_resto-directory/resto_directory.mli +++ b/vendors/ocplib-resto/lib_resto-directory/resto_directory.mli @@ -138,8 +138,8 @@ module Make (Encoding : ENCODING) : sig val register5: 'prefix directory -> - ('m, 'prefix, ((((unit * 'a) * 'b) * 'c) * 'd) * 'e, 'q , 'i, 'o, 'e) Service.t -> - ('a -> 'b -> 'c -> 'd -> 'e -> 'q -> 'i -> [< ('o, 'e) Answer.t ] Lwt.t) -> + ('m, 'prefix, ((((unit * 'a) * 'b) * 'c) * 'd) * 'f, 'q , 'i, 'o, 'e) Service.t -> + ('a -> 'b -> 'c -> 'd -> 'f -> 'q -> 'i -> [< ('o, 'e) Answer.t ] Lwt.t) -> 'prefix directory (** Registring dynamic subtree. *)