2016-09-08 21:13:10 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
2017-11-14 03:36:14 +04:00
|
|
|
(* Copyright (c) 2014 - 2017. *)
|
2016-09-08 21:13:10 +04:00
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
open Data_encoding
|
|
|
|
|
2016-12-01 21:27:53 +04:00
|
|
|
module Error = struct
|
|
|
|
|
|
|
|
let service =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2016-12-01 21:27:53 +04:00
|
|
|
~description: "Schema for all the RPC errors from the shell"
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2016-12-01 21:27:53 +04:00
|
|
|
~input: Data_encoding.empty
|
|
|
|
~output: Data_encoding.json_schema
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "errors")
|
2016-12-01 21:27:53 +04:00
|
|
|
|
|
|
|
let encoding =
|
2017-12-09 06:51:58 +04:00
|
|
|
let { RPC_service.meth ; uri ; _ } =
|
|
|
|
RPC_service.forge_request service () () in
|
2016-12-01 21:27:53 +04:00
|
|
|
describe
|
|
|
|
~description:
|
|
|
|
(Printf.sprintf
|
|
|
|
"The full list of error is available with \
|
2017-12-07 20:43:21 +04:00
|
|
|
the global RPC `%s %s`"
|
2017-12-09 06:51:58 +04:00
|
|
|
(RPC_service.string_of_meth meth) (Uri.path_and_query uri))
|
2016-12-01 21:27:53 +04:00
|
|
|
(conv
|
|
|
|
~schema:Json_schema.any
|
|
|
|
(fun exn -> `A (List.map json_of_error exn))
|
|
|
|
(function `A exns -> List.map error_of_json exns | _ -> [])
|
|
|
|
json)
|
|
|
|
|
|
|
|
let wrap param_encoding =
|
|
|
|
union [
|
2017-11-24 20:19:38 +04:00
|
|
|
case (Tag 0)
|
2016-12-01 21:27:53 +04:00
|
|
|
(obj1 (req "ok" param_encoding))
|
|
|
|
(function Ok x -> Some x | _ -> None)
|
|
|
|
(fun x -> Ok x) ;
|
2017-11-24 20:19:38 +04:00
|
|
|
case (Tag 1)
|
2016-12-01 21:27:53 +04:00
|
|
|
(obj1 (req "error" encoding))
|
|
|
|
(function Error x -> Some x | _ -> None)
|
|
|
|
(fun x -> Error x) ;
|
|
|
|
]
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
module Blocks = struct
|
|
|
|
|
|
|
|
type block = [
|
|
|
|
| `Genesis
|
|
|
|
| `Head of int | `Prevalidation
|
|
|
|
| `Test_head of int | `Test_prevalidation
|
|
|
|
| `Hash of Block_hash.t
|
2017-11-13 19:34:00 +04:00
|
|
|
]
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
type block_info = {
|
|
|
|
hash: Block_hash.t ;
|
2017-04-10 19:06:11 +04:00
|
|
|
net_id: Net_id.t ;
|
2017-04-10 15:01:22 +04:00
|
|
|
level: Int32.t ;
|
2017-04-12 20:22:40 +04:00
|
|
|
proto_level: int ; (* uint8 *)
|
2016-09-08 21:13:10 +04:00
|
|
|
predecessor: Block_hash.t ;
|
|
|
|
timestamp: Time.t ;
|
2017-09-29 20:43:13 +04:00
|
|
|
validation_passes: int ; (* uint8 *)
|
2017-03-30 15:16:21 +04:00
|
|
|
operations_hash: Operation_list_list_hash.t ;
|
2017-04-10 19:06:11 +04:00
|
|
|
fitness: MBytes.t list ;
|
2017-12-05 18:19:22 +04:00
|
|
|
context: Context_hash.t ;
|
2017-04-10 19:06:11 +04:00
|
|
|
data: MBytes.t ;
|
2017-11-14 02:27:19 +04:00
|
|
|
operations: (Operation_hash.t * Operation.t) list list option ;
|
2017-04-10 19:06:11 +04:00
|
|
|
protocol: Protocol_hash.t ;
|
2017-11-27 09:13:12 +04:00
|
|
|
test_network: Test_network_status.t ;
|
2016-09-08 21:13:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
let block_info_encoding =
|
2017-11-14 02:27:19 +04:00
|
|
|
let operation_encoding =
|
|
|
|
merge_objs
|
|
|
|
(obj1 (req "hash" Operation_hash.encoding))
|
|
|
|
Operation.encoding in
|
2016-09-08 21:13:10 +04:00
|
|
|
conv
|
2017-04-12 20:22:40 +04:00
|
|
|
(fun { hash ; net_id ; level ; proto_level ; predecessor ;
|
2017-09-29 20:43:13 +04:00
|
|
|
fitness ; timestamp ; protocol ;
|
2017-12-05 18:19:22 +04:00
|
|
|
validation_passes ; operations_hash ; context ; data ;
|
2017-04-10 23:14:17 +04:00
|
|
|
operations ; test_network } ->
|
2017-11-14 06:14:26 +04:00
|
|
|
((hash, net_id, operations, protocol, test_network),
|
2017-04-19 23:46:10 +04:00
|
|
|
{ Block_header.shell =
|
2017-11-14 06:14:26 +04:00
|
|
|
{ level ; proto_level ; predecessor ;
|
2017-12-05 18:19:22 +04:00
|
|
|
timestamp ; validation_passes ; operations_hash ; fitness ;
|
|
|
|
context } ;
|
2017-04-19 23:46:10 +04:00
|
|
|
proto = data }))
|
2017-11-14 06:14:26 +04:00
|
|
|
(fun ((hash, net_id, operations, protocol, test_network),
|
2017-04-19 23:46:10 +04:00
|
|
|
{ Block_header.shell =
|
2017-11-14 06:14:26 +04:00
|
|
|
{ level ; proto_level ; predecessor ;
|
2017-12-05 18:19:22 +04:00
|
|
|
timestamp ; validation_passes ; operations_hash ; fitness ;
|
|
|
|
context } ;
|
2017-04-19 23:46:10 +04:00
|
|
|
proto = data }) ->
|
2017-04-12 20:22:40 +04:00
|
|
|
{ hash ; net_id ; level ; proto_level ; predecessor ;
|
2017-09-29 20:43:13 +04:00
|
|
|
fitness ; timestamp ; protocol ;
|
2017-12-05 18:19:22 +04:00
|
|
|
validation_passes ; operations_hash ; context ; data ;
|
2017-04-10 23:14:17 +04:00
|
|
|
operations ; test_network })
|
2017-04-10 19:06:11 +04:00
|
|
|
(dynamic_size
|
|
|
|
(merge_objs
|
2017-11-14 06:14:26 +04:00
|
|
|
(obj5
|
2017-04-10 19:06:11 +04:00
|
|
|
(req "hash" Block_hash.encoding)
|
2017-11-14 06:14:26 +04:00
|
|
|
(req "net_id" Net_id.encoding)
|
2017-11-14 02:27:19 +04:00
|
|
|
(opt "operations" (dynamic_size (list (dynamic_size (list (dynamic_size operation_encoding))))))
|
2017-04-10 19:06:11 +04:00
|
|
|
(req "protocol" Protocol_hash.encoding)
|
2017-04-10 23:14:17 +04:00
|
|
|
(dft "test_network"
|
2017-11-27 09:13:12 +04:00
|
|
|
Test_network_status.encoding Not_running))
|
2017-04-19 23:46:10 +04:00
|
|
|
Block_header.encoding))
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
let parse_block s =
|
|
|
|
try
|
2017-11-27 09:13:12 +04:00
|
|
|
match String.split '~' s with
|
2016-09-08 21:13:10 +04:00
|
|
|
| ["genesis"] -> Ok `Genesis
|
|
|
|
| ["head"] -> Ok (`Head 0)
|
|
|
|
| ["prevalidation"] -> Ok `Prevalidation
|
|
|
|
| ["test_head"] -> Ok (`Test_head 0)
|
|
|
|
| ["test_prevalidation"] -> Ok `Test_prevalidation
|
|
|
|
| ["head"; n] -> Ok (`Head (int_of_string n))
|
|
|
|
| ["test_head"; n] -> Ok (`Test_head (int_of_string n))
|
2017-04-05 11:54:21 +04:00
|
|
|
| [h] -> Ok (`Hash (Block_hash.of_b58check_exn h))
|
2016-09-08 21:13:10 +04:00
|
|
|
| _ -> raise Exit
|
|
|
|
with _ -> Error "Cannot parse block identifier."
|
|
|
|
|
2017-03-15 04:17:20 +04:00
|
|
|
let to_string = function
|
|
|
|
| `Genesis -> "genesis"
|
|
|
|
| `Head 0 -> "head"
|
|
|
|
| `Head n -> Printf.sprintf "head~%d" n
|
|
|
|
| `Prevalidation -> "prevalidation"
|
|
|
|
| `Test_head 0 -> "test_head"
|
|
|
|
| `Test_head n -> Printf.sprintf "test_head~%d" n
|
|
|
|
| `Test_prevalidation -> "test_prevalidation"
|
|
|
|
| `Hash h -> Block_hash.to_b58check h
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
let blocks_arg =
|
|
|
|
let name = "block_id" in
|
|
|
|
let descr =
|
|
|
|
"A block identifier. This is either a block hash in hexadecimal \
|
|
|
|
notation or a one the predefined aliases: \
|
|
|
|
'genesis', 'head', 'prevalidation', \
|
|
|
|
'test_head' or 'test_prevalidation'. One might alse use 'head~N'
|
|
|
|
to 'test_head~N', where N is an integer to denotes the Nth predecessors
|
|
|
|
of 'head' or 'test_head'." in
|
2017-03-15 04:17:20 +04:00
|
|
|
let construct = to_string in
|
2016-09-08 21:13:10 +04:00
|
|
|
let destruct = parse_block in
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_arg.make ~name ~descr ~construct ~destruct ()
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-12-09 06:51:58 +04:00
|
|
|
let block_path : (unit, unit * block) RPC_path.path =
|
|
|
|
RPC_path.(root / "blocks" /: blocks_arg )
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
let info =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2017-03-08 21:47:01 +04:00
|
|
|
~description:"All the information about a block."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2017-04-10 19:06:11 +04:00
|
|
|
~input: (obj1 (dft "operations" bool true))
|
2016-09-08 21:13:10 +04:00
|
|
|
~output: block_info_encoding
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2016-09-08 21:13:10 +04:00
|
|
|
block_path
|
|
|
|
|
2017-04-20 10:26:43 +04:00
|
|
|
let net_id =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2016-09-08 21:13:10 +04:00
|
|
|
~description:"Returns the net of the chain in which the block belongs."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2016-09-08 21:13:10 +04:00
|
|
|
~input: empty
|
2017-04-20 10:26:43 +04:00
|
|
|
~output: (obj1 (req "net_id" Net_id.encoding))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(block_path / "net_id")
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-04-10 15:01:22 +04:00
|
|
|
let level =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2017-04-10 15:01:22 +04:00
|
|
|
~description:"Returns the block's level."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2017-04-10 15:01:22 +04:00
|
|
|
~input: empty
|
|
|
|
~output: (obj1 (req "level" int32))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(block_path / "level")
|
2017-04-10 15:01:22 +04:00
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
let predecessor =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2016-09-08 21:13:10 +04:00
|
|
|
~description:"Returns the previous block's id."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2016-09-08 21:13:10 +04:00
|
|
|
~input: empty
|
|
|
|
~output: (obj1 (req "predecessor" Block_hash.encoding))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(block_path / "predecessor")
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-15 23:38:00 +04:00
|
|
|
let predecessors =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2017-02-15 23:38:00 +04:00
|
|
|
~description:
|
|
|
|
"...."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2017-02-15 23:38:00 +04:00
|
|
|
~input: (obj1 (req "length" Data_encoding.uint16))
|
|
|
|
~output: (obj1
|
|
|
|
(req "blocks" (Data_encoding.list Block_hash.encoding)))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(block_path / "predecessors")
|
2017-02-15 23:38:00 +04:00
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
let hash =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2016-09-08 21:13:10 +04:00
|
|
|
~description:"Returns the block's id."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2016-09-08 21:13:10 +04:00
|
|
|
~input: empty
|
|
|
|
~output: (obj1 (req "hash" Block_hash.encoding))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(block_path / "hash")
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
let fitness =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2016-09-08 21:13:10 +04:00
|
|
|
~description:"Returns the block's fitness."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2016-09-08 21:13:10 +04:00
|
|
|
~input: empty
|
|
|
|
~output: (obj1 (req "fitness" Fitness.encoding))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(block_path / "fitness")
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-12-05 18:19:22 +04:00
|
|
|
let context =
|
|
|
|
RPC_service.post_service
|
|
|
|
~description:"Returns the hash of the resulting context."
|
|
|
|
~query: RPC_query.empty
|
|
|
|
~input: empty
|
|
|
|
~output: (obj1 (req "context" Context_hash.encoding))
|
|
|
|
~error: Data_encoding.empty
|
|
|
|
RPC_path.(block_path / "context")
|
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
let timestamp =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2016-09-08 21:13:10 +04:00
|
|
|
~description:"Returns the block's timestamp."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2016-09-08 21:13:10 +04:00
|
|
|
~input: empty
|
|
|
|
~output: (obj1 (req "timestamp" Time.encoding))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(block_path / "timestamp")
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-04-19 23:46:10 +04:00
|
|
|
type operations_param = {
|
|
|
|
contents: bool ;
|
|
|
|
monitor: bool ;
|
|
|
|
}
|
|
|
|
|
|
|
|
let operations_param_encoding =
|
|
|
|
let open Data_encoding in
|
|
|
|
conv
|
|
|
|
(fun { contents ; monitor } -> (contents, monitor))
|
|
|
|
(fun (contents, monitor) -> { contents ; monitor })
|
|
|
|
(obj2
|
|
|
|
(dft "contents" bool false)
|
|
|
|
(dft "monitor" bool false))
|
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
let operations =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2016-09-08 21:13:10 +04:00
|
|
|
~description:"List the block operations."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2017-04-19 23:46:10 +04:00
|
|
|
~input: operations_param_encoding
|
|
|
|
~output: (obj1
|
|
|
|
(req "operations"
|
|
|
|
(list (list
|
|
|
|
(obj2
|
|
|
|
(req "hash" Operation_hash.encoding)
|
|
|
|
(opt "contents"
|
|
|
|
(dynamic_size Operation.encoding)))))))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(block_path / "operations")
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
let protocol =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2016-09-08 21:13:10 +04:00
|
|
|
~description:"List the block protocol."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2016-09-08 21:13:10 +04:00
|
|
|
~input: empty
|
|
|
|
~output: (obj1 (req "protocol" Protocol_hash.encoding))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(block_path / "protocol")
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
let test_network =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2017-04-10 23:14:17 +04:00
|
|
|
~description:"Returns the status of the associated test network."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2016-09-08 21:13:10 +04:00
|
|
|
~input: empty
|
2017-11-27 09:13:12 +04:00
|
|
|
~output: Test_network_status.encoding
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(block_path / "test_network")
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
let pending_operations =
|
2017-11-14 02:27:19 +04:00
|
|
|
let operation_encoding =
|
|
|
|
merge_objs
|
|
|
|
(obj1 (req "hash" Operation_hash.encoding))
|
|
|
|
Operation.encoding in
|
2016-09-08 21:13:10 +04:00
|
|
|
(* TODO: branch_delayed/... *)
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2016-09-08 21:13:10 +04:00
|
|
|
~description:
|
|
|
|
"List the not-yet-prevalidated operations."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2016-09-08 21:13:10 +04:00
|
|
|
~input: empty
|
|
|
|
~output:
|
|
|
|
(conv
|
2017-11-14 02:27:19 +04:00
|
|
|
(fun (preapplied, unprocessed) ->
|
2017-11-27 09:13:12 +04:00
|
|
|
({ preapplied with
|
|
|
|
Preapply_result.refused = Operation_hash.Map.empty },
|
2017-11-14 02:27:19 +04:00
|
|
|
Operation_hash.Map.bindings unprocessed))
|
|
|
|
(fun (preapplied, unprocessed) ->
|
|
|
|
(preapplied,
|
|
|
|
List.fold_right
|
|
|
|
(fun (h, op) m -> Operation_hash.Map.add h op m)
|
|
|
|
unprocessed Operation_hash.Map.empty))
|
|
|
|
(merge_objs
|
|
|
|
(dynamic_size
|
2017-11-27 09:13:12 +04:00
|
|
|
(Preapply_result.encoding Error.encoding))
|
2017-11-14 02:27:19 +04:00
|
|
|
(obj1 (req "unprocessed" (list (dynamic_size operation_encoding))))))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(block_path / "pending_operations")
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
let proto_path =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(block_path / "proto")
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-04-27 03:01:05 +04:00
|
|
|
type preapply_param = {
|
|
|
|
timestamp: Time.t ;
|
|
|
|
proto_header: MBytes.t ;
|
2017-12-05 18:17:57 +04:00
|
|
|
operations: Operation.t list list ;
|
2017-04-27 03:01:05 +04:00
|
|
|
sort_operations: bool ;
|
|
|
|
}
|
|
|
|
|
|
|
|
let preapply_param_encoding =
|
|
|
|
(conv
|
|
|
|
(fun { timestamp ; proto_header ; operations ; sort_operations } ->
|
|
|
|
(timestamp, proto_header, operations, sort_operations))
|
|
|
|
(fun (timestamp, proto_header, operations, sort_operations) ->
|
|
|
|
{ timestamp ; proto_header ; operations ; sort_operations })
|
|
|
|
(obj4
|
|
|
|
(req "timestamp" Time.encoding)
|
|
|
|
(req "proto_header" bytes)
|
2017-12-05 18:17:57 +04:00
|
|
|
(req "operations" (list (dynamic_size (list (dynamic_size Operation.encoding)))))
|
2017-04-27 03:01:05 +04:00
|
|
|
(dft "sort_operations" bool false)))
|
|
|
|
|
|
|
|
type preapply_result = {
|
|
|
|
shell_header: Block_header.shell_header ;
|
2017-12-05 18:17:57 +04:00
|
|
|
operations: error Preapply_result.t list ;
|
2017-04-27 03:01:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
let preapply_result_encoding =
|
|
|
|
(conv
|
|
|
|
(fun { shell_header ; operations } ->
|
|
|
|
(shell_header, operations))
|
|
|
|
(fun (shell_header, operations) ->
|
|
|
|
{ shell_header ; operations })
|
|
|
|
(obj2
|
|
|
|
(req "shell_header" Block_header.shell_header_encoding)
|
|
|
|
(req "operations"
|
2017-12-05 18:17:57 +04:00
|
|
|
(list (Preapply_result.encoding Error.encoding)))))
|
2017-04-27 03:01:05 +04:00
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
let preapply =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2016-09-08 21:13:10 +04:00
|
|
|
~description:
|
|
|
|
"Simulate the validation of a block that would contain \
|
|
|
|
the given operations and return the resulting fitness."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2016-09-08 21:13:10 +04:00
|
|
|
~input: preapply_param_encoding
|
2016-12-01 21:27:53 +04:00
|
|
|
~output: (Error.wrap preapply_result_encoding)
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(block_path / "preapply")
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2016-11-14 19:26:34 +04:00
|
|
|
let complete =
|
|
|
|
let prefix_arg =
|
|
|
|
let destruct s = Ok s
|
|
|
|
and construct s = s in
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_arg.make ~name:"prefix" ~destruct ~construct () in
|
|
|
|
RPC_service.post_service
|
2017-02-19 21:22:32 +04:00
|
|
|
~description: "Try to complete a prefix of a Base58Check-encoded data. \
|
2016-11-14 19:26:34 +04:00
|
|
|
This RPC is actually able to complete hashes of \
|
|
|
|
block, operations, public_keys and contracts."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2016-11-14 19:26:34 +04:00
|
|
|
~input: empty
|
|
|
|
~output: (list string)
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(block_path / "complete" /: prefix_arg )
|
2016-11-14 19:26:34 +04:00
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
type list_param = {
|
2017-04-10 19:06:11 +04:00
|
|
|
include_ops: bool ;
|
2016-09-08 21:13:10 +04:00
|
|
|
length: int option ;
|
|
|
|
heads: Block_hash.t list option ;
|
|
|
|
monitor: bool option ;
|
|
|
|
delay: int option ;
|
2016-09-21 18:22:43 +04:00
|
|
|
min_date: Time.t option;
|
|
|
|
min_heads: int option;
|
2016-09-08 21:13:10 +04:00
|
|
|
}
|
|
|
|
let list_param_encoding =
|
|
|
|
conv
|
2017-04-10 19:06:11 +04:00
|
|
|
(fun { include_ops ; length ; heads ; monitor ;
|
2016-09-21 18:22:43 +04:00
|
|
|
delay ; min_date ; min_heads } ->
|
2017-04-10 19:06:11 +04:00
|
|
|
(include_ops, length, heads, monitor, delay, min_date, min_heads))
|
|
|
|
(fun (include_ops, length, heads, monitor,
|
|
|
|
delay, min_date, min_heads) ->
|
2017-11-13 19:34:00 +04:00
|
|
|
{ include_ops ; length ; heads ; monitor ;
|
|
|
|
delay ; min_date ; min_heads })
|
2017-04-10 19:06:11 +04:00
|
|
|
(obj7
|
|
|
|
(dft "include_ops"
|
2016-09-08 21:13:10 +04:00
|
|
|
(Data_encoding.describe
|
|
|
|
~description:
|
|
|
|
"Whether the resulting block informations should include the \
|
|
|
|
list of operations' hashes. Default false."
|
2017-03-22 20:21:52 +04:00
|
|
|
bool) false)
|
2016-09-08 21:13:10 +04:00
|
|
|
(opt "length"
|
|
|
|
(Data_encoding.describe
|
|
|
|
~description:
|
|
|
|
"The requested number of predecessors to returns (per \
|
|
|
|
requested head)."
|
|
|
|
int31))
|
|
|
|
(opt "heads"
|
|
|
|
(Data_encoding.describe
|
|
|
|
~description:
|
|
|
|
"An empty argument requests blocks from the current heads. \
|
|
|
|
A non empty list allow to request specific fragment \
|
|
|
|
of the chain."
|
|
|
|
(list Block_hash.encoding)))
|
|
|
|
(opt "monitor"
|
|
|
|
(Data_encoding.describe
|
|
|
|
~description:
|
|
|
|
"When true, the socket is \"kept alive\" after the first \
|
|
|
|
answer and new heads are streamed when discovered."
|
|
|
|
bool))
|
|
|
|
(opt "delay"
|
|
|
|
(Data_encoding.describe
|
|
|
|
~description:
|
|
|
|
"By default only the blocks that were validated by the node \
|
|
|
|
are considered. \
|
|
|
|
When this optional argument is 0, only blocks with a \
|
|
|
|
timestamp in the past are considered. Other values allows to \
|
|
|
|
adjust the current time."
|
2016-09-21 18:22:43 +04:00
|
|
|
int31))
|
|
|
|
(opt "min_date"
|
|
|
|
(Data_encoding.describe
|
|
|
|
~description: "When `min_date` is provided, heads with a \
|
|
|
|
timestamp before `min_date` are filtered ouf"
|
|
|
|
Time.encoding))
|
|
|
|
(opt "min_heads"
|
|
|
|
(Data_encoding.describe
|
|
|
|
~description:"When `min_date` is provided, returns at least \
|
|
|
|
`min_heads` even when their timestamp is before \
|
|
|
|
`min_date`."
|
2016-09-08 21:13:10 +04:00
|
|
|
int31)))
|
|
|
|
|
|
|
|
let list =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2016-09-08 21:13:10 +04:00
|
|
|
~description:
|
|
|
|
"Lists known heads of the blockchain sorted with decreasing fitness. \
|
|
|
|
Optional arguments allows to returns the list of predecessors for \
|
|
|
|
known heads or the list of predecessors for a given list of blocks."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2016-09-08 21:13:10 +04:00
|
|
|
~input: list_param_encoding
|
|
|
|
~output: (obj1 (req "blocks" (list (list block_info_encoding))))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "blocks")
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-11-27 01:21:56 +04:00
|
|
|
let list_invalid =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2017-11-27 01:21:56 +04:00
|
|
|
~description:
|
|
|
|
"Lists blocks that have been declared invalid along with the errors\
|
|
|
|
that led to them being declared invalid"
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2017-11-27 01:21:56 +04:00
|
|
|
~input:empty
|
|
|
|
~output:(Data_encoding.list
|
|
|
|
(obj3
|
|
|
|
(req "block" Block_hash.encoding)
|
|
|
|
(req "level" int32)
|
2017-11-27 01:59:57 +04:00
|
|
|
(req "errors" Error.encoding)))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "invalid_blocks")
|
2017-11-27 01:21:56 +04:00
|
|
|
|
2018-01-13 02:57:08 +04:00
|
|
|
let unmark_invalid =
|
|
|
|
RPC_service.post_service
|
|
|
|
~description:
|
|
|
|
"Unmark an invalid block"
|
|
|
|
~query: RPC_query.empty
|
|
|
|
~input:Data_encoding.(obj1 (req "block" Block_hash.encoding))
|
|
|
|
~output:(Error.wrap Data_encoding.empty)
|
|
|
|
~error: Data_encoding.empty
|
|
|
|
RPC_path.(root / "unmark_invalid")
|
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
end
|
|
|
|
|
2016-10-21 16:01:20 +04:00
|
|
|
module Protocols = struct
|
2017-03-30 16:31:16 +04:00
|
|
|
|
2017-12-08 22:10:08 +04:00
|
|
|
let protocols_arg = Protocol_hash.rpc_arg
|
2016-10-21 16:01:20 +04:00
|
|
|
|
2017-03-30 16:31:16 +04:00
|
|
|
let contents =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
|
|
|
~query: RPC_query.empty
|
2016-10-21 16:01:20 +04:00
|
|
|
~input: empty
|
|
|
|
~output:
|
|
|
|
(obj1 (req "data"
|
|
|
|
(describe ~title: "Tezos protocol"
|
2017-04-19 21:21:23 +04:00
|
|
|
(Protocol.encoding))))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "protocols" /: protocols_arg)
|
2016-10-21 16:01:20 +04:00
|
|
|
|
|
|
|
type list_param = {
|
|
|
|
contents: bool option ;
|
|
|
|
monitor: bool option ;
|
|
|
|
}
|
|
|
|
|
|
|
|
let list_param_encoding =
|
|
|
|
conv
|
|
|
|
(fun {contents; monitor} -> (contents, monitor))
|
|
|
|
(fun (contents, monitor) -> {contents; monitor})
|
|
|
|
(obj2
|
|
|
|
(opt "contents" bool)
|
|
|
|
(opt "monitor" bool))
|
|
|
|
|
|
|
|
let list =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
|
|
|
~query: RPC_query.empty
|
2016-10-21 16:01:20 +04:00
|
|
|
~input: list_param_encoding
|
|
|
|
~output:
|
|
|
|
(obj1
|
|
|
|
(req "protocols"
|
|
|
|
(list
|
|
|
|
(obj2
|
|
|
|
(req "hash" Protocol_hash.encoding)
|
|
|
|
(opt "contents"
|
2017-04-19 21:21:23 +04:00
|
|
|
(dynamic_size Protocol.encoding)))
|
2016-10-21 16:01:20 +04:00
|
|
|
)))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "protocols")
|
2017-03-30 16:31:16 +04:00
|
|
|
|
2016-10-21 16:01:20 +04:00
|
|
|
end
|
|
|
|
|
2018-01-22 21:04:20 +04:00
|
|
|
module Workers = struct
|
|
|
|
|
|
|
|
module Prevalidators = struct
|
|
|
|
|
|
|
|
let (net_id_arg : Net_id.t RPC_arg.t) =
|
|
|
|
RPC_arg.make
|
|
|
|
~name:"net_id"
|
|
|
|
~descr:"The network identifier of whom the prevalidator is responsible."
|
|
|
|
~destruct:(fun s -> try
|
|
|
|
Ok (Net_id.of_b58check_exn s)
|
|
|
|
with Failure msg -> Error msg)
|
|
|
|
~construct:Net_id.to_b58check
|
|
|
|
()
|
|
|
|
|
|
|
|
let list =
|
|
|
|
RPC_service.post_service
|
|
|
|
~description:"Lists the Prevalidator workers and their status."
|
|
|
|
~query: RPC_query.empty
|
|
|
|
~error: Data_encoding.empty
|
|
|
|
~input: empty
|
|
|
|
~output:
|
|
|
|
(list
|
|
|
|
(obj2
|
|
|
|
(req "net_id" Net_id.encoding)
|
|
|
|
(req "status" (Worker_types.worker_status_encoding Error.encoding))))
|
|
|
|
RPC_path.(root / "workers" / "prevalidators")
|
|
|
|
|
|
|
|
let state =
|
|
|
|
let open Data_encoding in
|
|
|
|
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
|
|
|
|
Prevalidator_worker_state.Request.encoding
|
|
|
|
(Prevalidator_worker_state.Event.encoding Error.encoding)
|
|
|
|
Error.encoding)
|
|
|
|
RPC_path.(root / "workers" / "prevalidators" /: net_id_arg )
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2018-01-22 21:05:26 +04:00
|
|
|
module Block_validator = struct
|
|
|
|
|
|
|
|
let state =
|
|
|
|
let open Data_encoding in
|
|
|
|
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
|
|
|
|
Block_validator_worker_state.Request.encoding
|
|
|
|
(Block_validator_worker_state.Event.encoding Error.encoding)
|
|
|
|
Error.encoding)
|
|
|
|
RPC_path.(root / "workers" / "block_validator")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2018-01-22 21:04:20 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2017-02-17 22:12:06 +04:00
|
|
|
module Network = struct
|
2017-02-24 19:20:10 +04:00
|
|
|
|
2017-02-17 22:12:06 +04:00
|
|
|
open P2p_types
|
2017-02-24 19:20:10 +04:00
|
|
|
|
2017-12-09 06:51:58 +04:00
|
|
|
let (peer_id_arg : P2p_types.Peer_id.t RPC_arg.arg) =
|
2017-12-08 22:10:08 +04:00
|
|
|
Crypto_box.Public_key_hash.rpc_arg
|
2017-02-17 22:12:06 +04:00
|
|
|
|
|
|
|
let point_arg =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_arg.make
|
2017-02-17 22:12:06 +04:00
|
|
|
~name:"point"
|
|
|
|
~descr:"A network point (ipv4:port or [ipv6]:port)."
|
|
|
|
~destruct:Point.of_string
|
|
|
|
~construct:Point.to_string
|
|
|
|
()
|
|
|
|
|
2017-03-13 21:08:45 +04:00
|
|
|
let versions =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2017-03-13 21:08:45 +04:00
|
|
|
~description:"Supported network layer versions."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2017-03-13 21:08:45 +04:00
|
|
|
~input: empty
|
2017-11-27 09:13:12 +04:00
|
|
|
~output: (list P2p_types.Version.encoding)
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "network" / "versions")
|
2017-03-13 21:08:45 +04:00
|
|
|
|
2017-02-17 22:12:06 +04:00
|
|
|
let stat =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2017-02-17 22:12:06 +04:00
|
|
|
~description:"Global network bandwidth statistics in B/s."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2017-02-17 22:12:06 +04:00
|
|
|
~input: empty
|
2017-11-27 09:13:12 +04:00
|
|
|
~output: P2p_types.Stat.encoding
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "network" / "stat")
|
2017-02-17 22:12:06 +04:00
|
|
|
|
|
|
|
let events =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2017-02-17 22:12:06 +04:00
|
|
|
~description:"Stream of all network events"
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2017-02-17 22:12:06 +04:00
|
|
|
~input: empty
|
2017-11-27 09:13:12 +04:00
|
|
|
~output: P2p_types.Connection_pool_log_event.encoding
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "network" / "log")
|
2017-02-17 22:12:06 +04:00
|
|
|
|
|
|
|
let connect =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2017-02-17 22:12:06 +04:00
|
|
|
~description:"Connect to a peer"
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2017-02-17 22:12:06 +04:00
|
|
|
~input: (obj1 (dft "timeout" float 5.))
|
|
|
|
~output: (Error.wrap @@ empty)
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "network" / "connect" /: point_arg)
|
2017-02-17 22:12:06 +04:00
|
|
|
|
|
|
|
let monitor_encoding = obj1 (dft "monitor" bool false)
|
|
|
|
|
|
|
|
module Connection = struct
|
2017-02-24 19:20:10 +04:00
|
|
|
|
2017-02-17 22:12:06 +04:00
|
|
|
let list =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2017-02-24 19:20:10 +04:00
|
|
|
~description:"List the running P2P connection."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2017-02-17 22:12:06 +04:00
|
|
|
~input: empty
|
2017-11-27 09:13:12 +04:00
|
|
|
~output: (list P2p_types.Connection_info.encoding)
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "network" / "connection")
|
2017-02-17 22:12:06 +04:00
|
|
|
|
|
|
|
let info =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
|
|
|
~query: RPC_query.empty
|
2017-02-17 22:12:06 +04:00
|
|
|
~input: empty
|
2017-11-27 09:13:12 +04:00
|
|
|
~output: (option P2p_types.Connection_info.encoding)
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-02-24 19:20:10 +04:00
|
|
|
~description:"Details about the current P2P connection to the given peer."
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "network" / "connection" /: peer_id_arg)
|
2017-02-17 22:12:06 +04:00
|
|
|
|
|
|
|
let kick =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
|
|
|
~query: RPC_query.empty
|
2017-02-17 22:12:06 +04:00
|
|
|
~input: (obj1 (req "wait" bool))
|
|
|
|
~output: empty
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-02-24 19:20:10 +04:00
|
|
|
~description:"Forced close of the current P2P connection to the given peer."
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "network" / "connection" /: peer_id_arg / "kick")
|
2017-02-24 19:20:10 +04:00
|
|
|
|
2017-02-17 22:12:06 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
module Point = struct
|
2017-02-24 19:20:10 +04:00
|
|
|
|
2017-02-17 22:12:06 +04:00
|
|
|
let info =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
|
|
|
~query: RPC_query.empty
|
2017-02-17 22:12:06 +04:00
|
|
|
~input: empty
|
2017-11-27 09:13:12 +04:00
|
|
|
~output: (option P2p_types.Point_info.encoding)
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-02-24 19:20:10 +04:00
|
|
|
~description: "Details about a given `IP:addr`."
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "network" / "point" /: point_arg)
|
2017-02-17 22:12:06 +04:00
|
|
|
|
|
|
|
let events =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
|
|
|
~query: RPC_query.empty
|
2017-02-17 22:12:06 +04:00
|
|
|
~input: monitor_encoding
|
2017-11-27 09:13:12 +04:00
|
|
|
~output: (list P2p_connection_pool_types.Point_info.Event.encoding)
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-02-24 19:20:10 +04:00
|
|
|
~description: "Monitor network events related to an `IP:addr`."
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "network" / "point" /: point_arg / "log")
|
2017-02-24 19:20:10 +04:00
|
|
|
|
2017-03-02 18:39:36 +04:00
|
|
|
let list =
|
2017-02-17 22:12:06 +04:00
|
|
|
let filter =
|
2017-11-27 09:13:12 +04:00
|
|
|
obj1 (dft "filter" (list P2p_types.Point_state.encoding) []) in
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
|
|
|
~query: RPC_query.empty
|
2017-02-17 22:12:06 +04:00
|
|
|
~input: filter
|
2017-11-27 09:13:12 +04:00
|
|
|
~output:
|
|
|
|
(list (tup2
|
|
|
|
P2p_types.Point.encoding
|
|
|
|
P2p_types.Point_info.encoding))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-03-02 18:39:36 +04:00
|
|
|
~description:"List the pool of known `IP:port` \
|
|
|
|
used for establishing P2P connections ."
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "network" / "point")
|
2017-03-02 18:39:36 +04:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
module Peer_id = struct
|
2017-02-17 22:12:06 +04:00
|
|
|
|
|
|
|
let info =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
|
|
|
~query: RPC_query.empty
|
2017-02-17 22:12:06 +04:00
|
|
|
~input: empty
|
2017-11-27 09:13:12 +04:00
|
|
|
~output: (option P2p_types.Peer_info.encoding)
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-02-24 19:20:10 +04:00
|
|
|
~description:"Details about a given peer."
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "network" / "peer_id" /: peer_id_arg)
|
2017-02-17 22:12:06 +04:00
|
|
|
|
|
|
|
let events =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
|
|
|
~query: RPC_query.empty
|
2017-02-17 22:12:06 +04:00
|
|
|
~input: monitor_encoding
|
2017-11-27 09:13:12 +04:00
|
|
|
~output: (list P2p_connection_pool_types.Peer_info.Event.encoding)
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-02-24 19:20:10 +04:00
|
|
|
~description:"Monitor network events related to a given peer."
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "network" / "peer_id" /: peer_id_arg / "log")
|
2017-02-24 19:20:10 +04:00
|
|
|
|
2017-03-02 18:39:36 +04:00
|
|
|
let list =
|
|
|
|
let filter =
|
2017-11-27 09:13:12 +04:00
|
|
|
obj1 (dft "filter" (list P2p_types.Peer_state.encoding) []) in
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
|
|
|
~query: RPC_query.empty
|
2017-03-02 18:39:36 +04:00
|
|
|
~input: filter
|
2017-11-27 09:13:12 +04:00
|
|
|
~output:
|
|
|
|
(list (tup2
|
|
|
|
P2p_types.Peer_id.encoding
|
|
|
|
P2p_types.Peer_info.encoding))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-03-02 18:39:36 +04:00
|
|
|
~description:"List the peers the node ever met."
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "network" / "peer_id")
|
2017-03-02 18:39:36 +04:00
|
|
|
|
2017-02-17 22:12:06 +04:00
|
|
|
end
|
2017-02-24 19:20:10 +04:00
|
|
|
|
2017-02-17 22:12:06 +04:00
|
|
|
end
|
|
|
|
|
2017-04-27 03:01:05 +04:00
|
|
|
let forge_block_header =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2016-09-08 21:13:10 +04:00
|
|
|
~description: "Forge a block header"
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2017-04-27 03:01:05 +04:00
|
|
|
~input: Block_header.encoding
|
2016-09-08 21:13:10 +04:00
|
|
|
~output: (obj1 (req "block" bytes))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "forge_block_header")
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-03-30 15:16:21 +04:00
|
|
|
type inject_block_param = {
|
|
|
|
raw: MBytes.t ;
|
|
|
|
blocking: bool ;
|
|
|
|
force: bool ;
|
2017-11-14 06:14:26 +04:00
|
|
|
net_id: Net_id.t option ;
|
2017-11-14 02:27:19 +04:00
|
|
|
operations: Operation.t list list ;
|
2017-03-30 15:16:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
let inject_block_param =
|
|
|
|
conv
|
2017-11-14 06:14:26 +04:00
|
|
|
(fun { raw ; blocking ; force ; net_id ; operations } ->
|
|
|
|
(raw, blocking, force, net_id, operations))
|
|
|
|
(fun (raw, blocking, force, net_id, operations) ->
|
|
|
|
{ raw ; blocking ; force ; net_id ; operations })
|
|
|
|
(obj5
|
2017-03-30 15:16:21 +04:00
|
|
|
(req "data" bytes)
|
|
|
|
(dft "blocking"
|
|
|
|
(describe
|
|
|
|
~description:
|
|
|
|
"Should the RPC wait for the block to be \
|
|
|
|
validated before answering. (default: true)"
|
|
|
|
bool)
|
|
|
|
true)
|
|
|
|
(dft "force"
|
|
|
|
(describe
|
|
|
|
~description:
|
|
|
|
"Should we inject the block when its fitness is below \
|
|
|
|
the current head. (default: false)"
|
|
|
|
bool)
|
|
|
|
false)
|
2017-11-14 06:14:26 +04:00
|
|
|
(opt "net_id" Net_id.encoding)
|
2017-03-30 15:16:21 +04:00
|
|
|
(req "operations"
|
|
|
|
(describe
|
|
|
|
~description:"..."
|
2017-11-14 02:27:19 +04:00
|
|
|
(list (list (dynamic_size Operation.encoding))))))
|
2017-03-30 15:16:21 +04:00
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
let inject_block =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2016-09-08 21:13:10 +04:00
|
|
|
~description:
|
|
|
|
"Inject a block in the node and broadcast it. The `operations` \
|
2017-03-30 15:16:21 +04:00
|
|
|
embedded in `blockHeader` might be pre-validated using a \
|
2016-09-08 21:13:10 +04:00
|
|
|
contextual RPCs from the latest block \
|
|
|
|
(e.g. '/blocks/head/context/preapply'). Returns the ID of the \
|
|
|
|
block. By default, the RPC will wait for the block to be \
|
2017-03-08 21:47:01 +04:00
|
|
|
validated before answering."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2017-03-30 15:16:21 +04:00
|
|
|
~input: inject_block_param
|
2016-09-08 21:13:10 +04:00
|
|
|
~output:
|
2016-12-01 21:27:53 +04:00
|
|
|
(Error.wrap @@
|
2016-09-08 21:13:10 +04:00
|
|
|
(obj1 (req "block_hash" Block_hash.encoding)))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "inject_block")
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
let inject_operation =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2016-09-08 21:13:10 +04:00
|
|
|
~description:
|
|
|
|
"Inject an operation in node and broadcast it. Returns the \
|
|
|
|
ID of the operation. The `signedOperationContents` should be \
|
|
|
|
constructed using a contextual RPCs from the latest block \
|
|
|
|
and signed by the client. By default, the RPC will wait for \
|
2017-03-08 21:47:01 +04:00
|
|
|
the operation to be (pre-)validated before answering. See \
|
2017-11-01 13:49:46 +04:00
|
|
|
RPCs under /blocks/prevalidation for more details on the \
|
2016-09-08 21:13:10 +04:00
|
|
|
prevalidation context."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2016-09-08 21:13:10 +04:00
|
|
|
~input:
|
2017-11-23 19:39:33 +04:00
|
|
|
(obj3
|
2017-01-23 14:09:55 +04:00
|
|
|
(req "signedOperationContents"
|
|
|
|
(describe ~title: "Tezos signed operation (hex encoded)"
|
|
|
|
bytes))
|
|
|
|
(dft "blocking"
|
|
|
|
(describe
|
|
|
|
~description:
|
|
|
|
"Should the RPC wait for the operation to be \
|
2017-03-08 21:47:01 +04:00
|
|
|
(pre-)validated before answering. (default: true)"
|
2017-01-23 14:09:55 +04:00
|
|
|
bool)
|
|
|
|
true)
|
2017-11-23 19:39:33 +04:00
|
|
|
(opt "net_id" Net_id.encoding))
|
2016-09-08 21:13:10 +04:00
|
|
|
~output:
|
2016-12-01 21:27:53 +04:00
|
|
|
(Error.wrap @@
|
2016-09-08 21:13:10 +04:00
|
|
|
describe
|
|
|
|
~title: "Hash of the injected operation" @@
|
|
|
|
(obj1 (req "injectedOperation" Operation_hash.encoding)))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "inject_operation")
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2016-10-21 16:01:20 +04:00
|
|
|
let inject_protocol =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2016-10-21 16:01:20 +04:00
|
|
|
~description:
|
|
|
|
"Inject a protocol in node. Returns the ID of the protocol."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2016-10-21 16:01:20 +04:00
|
|
|
~input:
|
2017-01-23 14:09:55 +04:00
|
|
|
(obj3
|
|
|
|
(req "protocol"
|
2017-10-09 12:55:12 +04:00
|
|
|
(describe ~title: "Tezos protocol" Protocol.encoding))
|
2017-01-23 14:09:55 +04:00
|
|
|
(dft "blocking"
|
|
|
|
(describe
|
|
|
|
~description:
|
|
|
|
"Should the RPC wait for the protocol to be \
|
2017-03-08 21:47:01 +04:00
|
|
|
validated before answering. (default: true)"
|
2017-01-23 14:09:55 +04:00
|
|
|
bool)
|
|
|
|
true)
|
|
|
|
(opt "force"
|
|
|
|
(describe
|
|
|
|
~description:
|
|
|
|
"Should we inject protocol that is invalid. (default: false)"
|
|
|
|
bool)))
|
2016-10-21 16:01:20 +04:00
|
|
|
~output:
|
2016-12-01 21:27:53 +04:00
|
|
|
(Error.wrap @@
|
2016-10-21 16:01:20 +04:00
|
|
|
describe
|
|
|
|
~title: "Hash of the injected protocol" @@
|
|
|
|
(obj1 (req "injectedProtocol" Protocol_hash.encoding)))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "inject_protocol")
|
2016-10-21 16:01:20 +04:00
|
|
|
|
2017-02-28 03:48:22 +04:00
|
|
|
let bootstrapped =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.post_service
|
2017-02-28 03:48:22 +04:00
|
|
|
~description:""
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2017-02-28 03:48:22 +04:00
|
|
|
~input: empty
|
|
|
|
~output: (obj2
|
|
|
|
(req "block" Block_hash.encoding)
|
|
|
|
(req "timestamp" Time.encoding))
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "bootstrapped")
|
2017-02-28 03:48:22 +04:00
|
|
|
|
2016-10-16 23:57:56 +04:00
|
|
|
let complete =
|
|
|
|
let prefix_arg =
|
|
|
|
let destruct s = Ok s
|
|
|
|
and construct s = s in
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_arg.make ~name:"prefix" ~destruct ~construct () in
|
|
|
|
RPC_service.post_service
|
2017-02-19 21:22:32 +04:00
|
|
|
~description: "Try to complete a prefix of a Base58Check-encoded data. \
|
2016-10-16 23:57:56 +04:00
|
|
|
This RPC is actually able to complete hashes of \
|
2016-11-14 19:26:34 +04:00
|
|
|
block and hashes of operations."
|
2017-12-09 06:51:58 +04:00
|
|
|
~query: RPC_query.empty
|
2016-10-16 23:57:56 +04:00
|
|
|
~input: empty
|
|
|
|
~output: (list string)
|
2017-12-07 20:43:21 +04:00
|
|
|
~error: Data_encoding.empty
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "complete" /: prefix_arg )
|
2016-10-16 23:57:56 +04:00
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
let describe =
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_service.description_service
|
2016-09-08 21:13:10 +04:00
|
|
|
~description: "RPCs documentation and input/output schema"
|
2017-12-09 06:51:58 +04:00
|
|
|
RPC_path.(root / "describe")
|