2016-09-08 21:13:10 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
2018-02-06 00:17:03 +04:00
|
|
|
(* Copyright (c) 2014 - 2018. *)
|
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
|
|
|
|
|
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-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:
|
2018-01-22 21:58:43 +04:00
|
|
|
(RPC_error.wrap @@
|
2016-09-08 21:13:10 +04:00
|
|
|
(obj1 (req "block_hash" Block_hash.encoding)))
|
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:
|
2018-01-22 21:58:43 +04:00
|
|
|
(RPC_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-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:
|
2018-01-22 21:58:43 +04:00
|
|
|
(RPC_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-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-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-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")
|