ligo/src/lib_shell_services/shell_services.ml

159 lines
5.4 KiB
OCaml
Raw Normal View History

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
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
~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
type inject_block_param = {
raw: MBytes.t ;
blocking: bool ;
force: bool ;
net_id: Net_id.t option ;
operations: Operation.t list list ;
}
let inject_block_param =
conv
(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
(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)
(opt "net_id" Net_id.encoding)
(req "operations"
(describe
~description:"..."
(list (list (dynamic_size Operation.encoding))))))
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` \
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
~input: inject_block_param
2016-09-08 21:13:10 +04:00
~output:
(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:
(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"
(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:
(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
let bootstrapped =
2017-12-09 06:51:58 +04:00
RPC_service.post_service
~description:""
2017-12-09 06:51:58 +04:00
~query: RPC_query.empty
~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")
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
~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 \
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")