2017-04-05 01:35:41 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
2017-11-14 03:36:14 +04:00
|
|
|
(* Copyright (c) 2014 - 2017. *)
|
2017-04-05 01:35:41 +04:00
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
type config = {
|
|
|
|
host : string ;
|
|
|
|
port : int ;
|
|
|
|
tls : bool ;
|
|
|
|
logger : logger ;
|
|
|
|
}
|
|
|
|
|
|
|
|
and logger =
|
|
|
|
Logger : {
|
|
|
|
log_request : Uri.t -> Data_encoding.json -> 'a Lwt.t ;
|
|
|
|
log_success :
|
|
|
|
'a -> Cohttp.Code.status_code -> Data_encoding.json -> unit Lwt.t ;
|
|
|
|
log_error :
|
|
|
|
'a -> Cohttp.Code.status_code -> string -> unit Lwt.t ;
|
|
|
|
} -> logger
|
|
|
|
|
2017-11-07 20:38:11 +04:00
|
|
|
class type rpc_sig = object
|
|
|
|
method get_json :
|
|
|
|
RPC.meth ->
|
|
|
|
string list -> Data_encoding.json ->
|
2017-12-07 20:43:21 +04:00
|
|
|
Data_encoding.json tzresult Lwt.t
|
2017-11-07 20:38:11 +04:00
|
|
|
method get_streamed_json :
|
|
|
|
RPC.meth ->
|
|
|
|
string list ->
|
|
|
|
Data_encoding.json ->
|
2017-12-07 20:43:21 +04:00
|
|
|
Data_encoding.json tzresult Lwt_stream.t tzresult Lwt.t
|
2017-11-07 20:38:11 +04:00
|
|
|
method make_request :
|
|
|
|
(Uri.t -> Data_encoding.json -> 'a Lwt.t) ->
|
|
|
|
RPC.meth ->
|
|
|
|
string list ->
|
|
|
|
Data_encoding.json ->
|
2017-12-07 20:43:21 +04:00
|
|
|
('a * Cohttp.Code.status_code * Cohttp_lwt.Body.t) tzresult Lwt.t
|
2017-11-07 20:38:11 +04:00
|
|
|
method parse_answer :
|
2017-12-07 20:43:21 +04:00
|
|
|
'meth 'params 'input 'output.
|
|
|
|
([< Resto.meth ] as 'meth, unit, 'params, unit, 'input, 'output, unit) RPC.Service.t ->
|
2017-11-07 20:38:11 +04:00
|
|
|
string list ->
|
2017-12-07 20:43:21 +04:00
|
|
|
Data_encoding.json -> 'output tzresult Lwt.t
|
2017-11-07 20:38:11 +04:00
|
|
|
method parse_err_answer :
|
2017-12-07 20:43:21 +04:00
|
|
|
'meth 'params 'input 'output.
|
|
|
|
([< Resto.meth ] as 'meth, unit, 'params, unit, 'input, 'output tzresult, unit) RPC.Service.t ->
|
2017-11-07 20:38:11 +04:00
|
|
|
string list ->
|
2017-12-07 20:43:21 +04:00
|
|
|
Data_encoding.json -> 'output tzresult Lwt.t
|
2017-11-07 20:38:11 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
class rpc : config -> rpc_sig
|
|
|
|
|
2017-04-05 01:35:41 +04:00
|
|
|
val default_config: config
|
|
|
|
val null_logger: logger
|
|
|
|
val timings_logger: Format.formatter -> logger
|
|
|
|
val full_logger: Format.formatter -> logger
|
|
|
|
|
|
|
|
val call_service0:
|
2017-11-07 20:38:11 +04:00
|
|
|
#rpc_sig ->
|
2017-12-07 20:43:21 +04:00
|
|
|
([ `POST ], unit,
|
|
|
|
unit, unit, 'i,
|
|
|
|
'o, unit) RPC.Service.t ->
|
2017-04-05 01:35:41 +04:00
|
|
|
'i -> 'o tzresult Lwt.t
|
|
|
|
|
|
|
|
val call_service1:
|
2017-11-07 20:38:11 +04:00
|
|
|
#rpc_sig ->
|
2017-12-07 20:43:21 +04:00
|
|
|
([ `POST ], unit,
|
|
|
|
unit * 'a, unit, 'i,
|
|
|
|
'o, unit) RPC.Service.t ->
|
2017-04-05 01:35:41 +04:00
|
|
|
'a -> 'i -> 'o tzresult Lwt.t
|
|
|
|
|
|
|
|
val call_service2:
|
2017-11-07 20:38:11 +04:00
|
|
|
#rpc_sig ->
|
2017-12-07 20:43:21 +04:00
|
|
|
([ `POST ], unit,
|
|
|
|
(unit * 'a) * 'b, unit, 'i,
|
|
|
|
'o, unit) RPC.Service.t ->
|
2017-04-05 01:35:41 +04:00
|
|
|
'a -> 'b -> 'i -> 'o tzresult Lwt.t
|
|
|
|
|
|
|
|
val call_streamed_service0:
|
2017-11-07 20:38:11 +04:00
|
|
|
#rpc_sig ->
|
2017-12-07 20:43:21 +04:00
|
|
|
([ `POST ], unit,
|
|
|
|
unit, unit, 'a,
|
|
|
|
'b, unit) RPC.Service.t ->
|
2017-12-07 20:43:21 +04:00
|
|
|
'a -> 'b tzresult Lwt_stream.t tzresult Lwt.t
|
2017-04-05 01:35:41 +04:00
|
|
|
|
2017-04-19 23:46:10 +04:00
|
|
|
val call_streamed_service1:
|
2017-11-07 20:38:11 +04:00
|
|
|
#rpc_sig ->
|
2017-12-07 20:43:21 +04:00
|
|
|
([ `POST ], unit,
|
|
|
|
unit * 'a, unit, 'b,
|
|
|
|
'c, unit) RPC.Service.t ->
|
2017-12-07 20:43:21 +04:00
|
|
|
'a -> 'b -> 'c tzresult Lwt_stream.t tzresult Lwt.t
|
2017-04-19 23:46:10 +04:00
|
|
|
|
2017-04-05 01:35:41 +04:00
|
|
|
val call_err_service0:
|
2017-11-07 20:38:11 +04:00
|
|
|
#rpc_sig ->
|
2017-12-07 20:43:21 +04:00
|
|
|
([ `POST ], unit,
|
|
|
|
unit, unit, 'i,
|
|
|
|
'o tzresult, unit) RPC.Service.t ->
|
2017-04-05 01:35:41 +04:00
|
|
|
'i -> 'o tzresult Lwt.t
|
|
|
|
|
|
|
|
val call_err_service1:
|
2017-11-07 20:38:11 +04:00
|
|
|
#rpc_sig ->
|
2017-12-07 20:43:21 +04:00
|
|
|
([ `POST ], unit,
|
|
|
|
unit * 'a, unit, 'i,
|
|
|
|
'o tzresult, unit) RPC.Service.t ->
|
2017-04-05 01:35:41 +04:00
|
|
|
'a -> 'i -> 'o tzresult Lwt.t
|
|
|
|
|
|
|
|
val call_err_service2:
|
2017-11-07 20:38:11 +04:00
|
|
|
#rpc_sig ->
|
2017-12-07 20:43:21 +04:00
|
|
|
([ `POST ], unit,
|
|
|
|
(unit * 'a) * 'b, unit, 'i,
|
|
|
|
'o tzresult, unit) RPC.Service.t ->
|
2017-04-05 01:35:41 +04:00
|
|
|
'a -> 'b -> 'i -> 'o tzresult Lwt.t
|
|
|
|
|
2017-04-20 10:26:43 +04:00
|
|
|
type block = Node_rpc_services.Blocks.block
|
|
|
|
|
2017-11-20 06:37:06 +04:00
|
|
|
val last_baked_block:
|
2017-04-20 10:26:43 +04:00
|
|
|
block -> [>
|
|
|
|
| `Genesis
|
|
|
|
| `Head of int
|
|
|
|
| `Test_head of int
|
|
|
|
| `Hash of Block_hash.t
|
|
|
|
]
|