RPC: remove the deprecated value RPC.service

This commit is contained in:
Grégoire Henry 2017-12-07 17:43:21 +01:00 committed by Benjamin Canou
parent 7ac969beb1
commit bfb6694afb
7 changed files with 288 additions and 123 deletions

View File

@ -36,34 +36,42 @@ let wrap_tzerror encoding =
let operations custom_root =
RPC.service
RPC.Service.post_service
~description: "All the operations of the block (fully decoded)."
~query: RPC.Query.empty
~input: empty
~output: (wrap_tzerror @@
(list (list (dynamic_size Operation.encoding))))
~error: Data_encoding.empty
RPC.Path.(custom_root / "operations")
let header custom_root =
RPC.service
RPC.Service.post_service
~description: "The header of the block (fully decoded)."
~query: RPC.Query.empty
~input: empty
~output: (wrap_tzerror Block_header.encoding)
~error: Data_encoding.empty
RPC.Path.(custom_root / "header")
module Header = struct
let priority custom_root =
RPC.service
RPC.Service.post_service
~description: "Baking priority of the block."
~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 =
RPC.service
RPC.Service.post_service
~description: "Hash of the seed nonce of the block."
~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
@ -71,74 +79,92 @@ end
module Constants = struct
let cycle_length custom_root =
RPC.service
RPC.Service.post_service
~description: "Cycle length"
~query: RPC.Query.empty
~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 =
RPC.service
RPC.Service.post_service
~description: "Length of the voting period"
~query: RPC.Query.empty
~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 =
RPC.service
RPC.Service.post_service
~description: "Time before reward"
~query: RPC.Query.empty
~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 =
RPC.service
RPC.Service.post_service
~description: "Slot durations"
~query: RPC.Query.empty
~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 =
RPC.service
RPC.Service.post_service
~description: "First free baking slot"
~query: RPC.Query.empty
~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 =
RPC.service
RPC.Service.post_service
~description: "Max signing slot"
~query: RPC.Query.empty
~input: empty
~output: (wrap_tzerror @@
describe ~title: "max signing slot" uint16)
~error: Data_encoding.empty
RPC.Path.(custom_root / "constants" / "max_signing_slot")
let instructions_per_transaction custom_root =
RPC.service
RPC.Service.post_service
~description: "Instructions per transaction"
~query: RPC.Query.empty
~input: empty
~output: (wrap_tzerror @@
describe ~title: "instructions per transaction" int31)
~error: Data_encoding.empty
RPC.Path.(custom_root / "constants" / "instructions_per_transaction")
let proof_of_work_threshold custom_root =
RPC.service
RPC.Service.post_service
~description: "Stamp threshold"
~query: RPC.Query.empty
~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 =
RPC.service
RPC.Service.post_service
~description: "Schema for all the RPC errors from this protocol version"
~query: RPC.Query.empty
~input: empty
~output: json_schema
~error: Data_encoding.empty
RPC.Path.(custom_root / "constants" / "errors")
end
@ -146,41 +172,51 @@ end
module Context = struct
let level custom_root =
RPC.service
RPC.Service.post_service
~description: "Detailled level information for the current block"
~query: RPC.Query.empty
~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 =
RPC.service
RPC.Service.post_service
~description: "Detailled level information for the next block"
~query: RPC.Query.empty
~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 =
RPC.service
RPC.Service.post_service
~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 =
RPC.service
RPC.Service.post_service
~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 =
RPC.service
RPC.Service.post_service
~description: "Voting period kind for the current block"
~query: RPC.Query.empty
~input: empty
~output:
(wrap_tzerror @@
(obj1
(req "voting_period_kind" Voting_period.kind_encoding)))
~error: Data_encoding.empty
RPC.Path.(custom_root / "context" / "voting_period_kind")
@ -208,18 +244,22 @@ module Context = struct
]
let get custom_root =
RPC.service
RPC.Service.post_service
~description: "Info about the nonce of a previous block."
~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 =
RPC.service
RPC.Service.post_service
~description: "Hash of the current block's nonce."
~query: RPC.Query.empty
~input: empty
~output: (wrap_tzerror @@
describe ~title: "nonce hash" Nonce_hash.encoding)
~error: Data_encoding.empty
RPC.Path.(custom_root / "context" / "nonce")
end
@ -245,17 +285,21 @@ module Context = struct
(req "public_key" Ed25519.Public_key.encoding))
let list custom_root =
RPC.service
RPC.Service.post_service
~description: "List the known public keys"
~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 =
RPC.service
RPC.Service.post_service
~description: "Fetch the stored public key"
~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
@ -265,59 +309,75 @@ module Context = struct
module Contract = struct
let balance custom_root =
RPC.service
RPC.Service.post_service
~description: "Access the balance of a contract."
~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 =
RPC.service
RPC.Service.post_service
~description: "Access the manager of a contract."
~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 =
RPC.service
RPC.Service.post_service
~description: "Access the delegate of a contract, if any."
~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 =
RPC.service
RPC.Service.post_service
~description: "Access the counter of a contract, if any."
~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 =
RPC.service
RPC.Service.post_service
~description: "Tells if the contract tokens can be spent by the manager."
~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 =
RPC.service
RPC.Service.post_service
~description: "Tells if the contract delegate can be changed."
~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 =
RPC.service
RPC.Service.post_service
~description: "Access the code and data of the contract."
~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 =
RPC.service
RPC.Service.post_service
~description: "Access the data of the contract."
~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 = {
@ -330,8 +390,9 @@ module Context = struct
}
let get custom_root =
RPC.service
RPC.Service.post_service
~description: "Access the complete status of a contract."
~query: RPC.Query.empty
~input: empty
~output:
(wrap_tzerror @@
@ -349,14 +410,17 @@ 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 =
RPC.service
RPC.Service.post_service
~description:
"All existing contracts (including non-empty default contracts)."
~query: RPC.Query.empty
~input: empty
~output: (wrap_tzerror @@ list Contract.encoding)
~error: Data_encoding.empty
RPC.Path.(custom_root / "context" / "contracts")
end
@ -368,11 +432,13 @@ end
module Helpers = struct
let minimal_timestamp custom_root =
RPC.service
RPC.Service.post_service
~description: "Minimal timestamp for the next block."
~query: RPC.Query.empty
~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 =
@ -385,18 +451,21 @@ module Helpers = struct
(opt "origination_nonce" Contract.origination_nonce_encoding))
let run_code custom_root =
RPC.service
RPC.Service.post_service
~description: "Run a piece of code in the current context"
~query: RPC.Query.empty
~input: run_code_input_encoding
~output: (wrap_tzerror
(obj2
(req "storage" Script.expr_encoding)
(req "output" Script.expr_encoding)))
~error: Data_encoding.empty
RPC.Path.(custom_root / "helpers" / "run_code")
let apply_operation custom_root =
RPC.service
RPC.Service.post_service
~description: "Applies an operation in the current context"
~query: RPC.Query.empty
~input: (obj4
(req "pred_block" Block_hash.encoding)
(req "operation_hash" Operation_hash.encoding)
@ -404,13 +473,15 @@ 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")
let trace_code custom_root =
RPC.service
RPC.Service.post_service
~description: "Run a piece of code in the current context, \
keeping a trace"
~query: RPC.Query.empty
~input: run_code_input_encoding
~output: (wrap_tzerror
(obj3
@ -421,52 +492,63 @@ module Helpers = struct
(req "location" Script.location_encoding)
(req "gas" int31)
(req "stack" (list (Script.expr_encoding)))))))
~error: Data_encoding.empty
RPC.Path.(custom_root / "helpers" / "trace_code")
let typecheck_code custom_root =
RPC.service
RPC.Service.post_service
~description: "Typecheck a piece of code in the current context"
~query: RPC.Query.empty
~input: Script.expr_encoding
~output: (wrap_tzerror Script_ir_translator.type_map_enc)
~error: Data_encoding.empty
RPC.Path.(custom_root / "helpers" / "typecheck_code")
let typecheck_data custom_root =
RPC.service
RPC.Service.post_service
~description: "Check that some data expression is well formed \
and of a given type in the current context"
~query: RPC.Query.empty
~input: (obj2
(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 =
RPC.service
RPC.Service.post_service
~description: "Computes the hash of some data expression \
using the same algorithm as script instruction H"
~query: RPC.Query.empty
~input: (obj1 (req "data" Script.expr_encoding))
~output: (wrap_tzerror @@
obj1 (req "hash" string))
~error: Data_encoding.empty
RPC.Path.(custom_root / "helpers" / "hash_data")
let level custom_root =
RPC.service
RPC.Service.post_service
~description: "..."
~query: RPC.Query.empty
~input: (obj1
(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 =
RPC.service
RPC.Service.post_service
~description: "Levels of a cycle"
~query: RPC.Query.empty
~input: empty
~output: (wrap_tzerror @@
describe ~title: "levels of a cycle"
(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
@ -489,10 +571,11 @@ module Helpers = struct
(req "timestamp" Timestamp.encoding))
let baking_rights custom_root =
RPC.service
RPC.Service.post_service
~description:
"List gelegates allowed to bake for the next level, \
ordered by priority."
~query: RPC.Query.empty
~input: (obj1 (opt "max_priority" int31))
~output: (wrap_tzerror @@
obj2
@ -502,102 +585,121 @@ 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 =
RPC.service
RPC.Service.post_service
~description:
"List delegate allowed to bake for a given level, \
ordered by priority."
~query: RPC.Query.empty
~input: (obj1 (opt "max_priority" int31))
~output: (wrap_tzerror @@
obj2
(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 )
let baking_levels custom_root =
RPC.service
RPC.Service.post_service
~description:
"List level for which we might computed baking rights."
~query: RPC.Query.empty
~input: empty
~output: (wrap_tzerror @@
obj1 (req "levels" (list Raw_level.encoding)))
~error: Data_encoding.empty
RPC.Path.(custom_root / "helpers" / "rights"
/ "baking" / "level" )
let baking_rights_for_delegate custom_root =
RPC.service
RPC.Service.post_service
~description: "Future baking rights for a given delegate."
~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 )
let baking_delegates custom_root =
RPC.service
RPC.Service.post_service
~description:
"List delegates with baking rights."
~query: RPC.Query.empty
~input: empty
~output: (wrap_tzerror @@
obj1 (req "delegates"
(list Ed25519.Public_key_hash.encoding)))
~error: Data_encoding.empty
RPC.Path.(custom_root / "helpers" / "rights"
/ "baking" / "delegate" )
let endorsement_rights custom_root =
RPC.service
RPC.Service.post_service
~description:
"List delegates allowed to endorse for the current block."
~query: RPC.Query.empty
~input: (obj1 (opt "max_priority" int31))
~output: (wrap_tzerror @@
obj2
(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 =
RPC.service
RPC.Service.post_service
~description:
"List delegates allowed to endorse blocks for a given level."
~query: RPC.Query.empty
~input: (obj1 (opt "max_priority" int31))
~output: (wrap_tzerror @@
obj2
(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 )
let endorsement_levels custom_root =
RPC.service
RPC.Service.post_service
~description:
"List level for which we might computed endorsement rights."
~query: RPC.Query.empty
~input: empty
~output: (wrap_tzerror @@
obj1 (req "levels" (list Raw_level.encoding)))
~error: Data_encoding.empty
RPC.Path.(custom_root / "helpers" / "rights"
/ "endorsement" / "level" )
let endorsement_rights_for_delegate custom_root =
RPC.service
RPC.Service.post_service
~description: "Compute endorsement rights for a given delegate."
~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 )
let endorsement_delegates custom_root =
RPC.service
RPC.Service.post_service
~description:
"List delegates with endorsement rights."
~query: RPC.Query.empty
~input: empty
~output: (wrap_tzerror @@
obj1 (req "delegates"
(list Ed25519.Public_key_hash.encoding)))
~error: Data_encoding.empty
RPC.Path.(custom_root / "helpers" / "rights"
/ "endorsement" / "delegate" )
@ -606,14 +708,16 @@ module Helpers = struct
module Forge = struct
let operations custom_root =
RPC.service
RPC.Service.post_service
~description:"Forge an operation"
~query: RPC.Query.empty
~input: Operation.unsigned_operation_encoding
~output:
(wrap_tzerror @@
(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 =
@ -621,8 +725,9 @@ module Helpers = struct
(String.make Constants_repr.proof_of_work_nonce_size '\000')
let block_proto_header custom_root =
RPC.service
RPC.Service.post_service
~description: "Forge the protocol-specific part of a block header"
~query: RPC.Query.empty
~input:
(obj3
(req "priority" uint16)
@ -632,6 +737,7 @@ 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
@ -639,21 +745,25 @@ module Helpers = struct
module Parse = struct
let operations custom_root =
RPC.service
RPC.Service.post_service
~description:"Parse operations"
~query: RPC.Query.empty
~input:
(obj2
(req "operations" (list (dynamic_size Operation.raw_encoding)))
(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 =
RPC.service
RPC.Service.post_service
~description:"Parse a block"
~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

View File

@ -32,17 +32,21 @@ let wrap_tzerror encoding =
]
let echo_service custom_root =
RPC.service
RPC.Service.post_service
~description: "An dummy echo service"
~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 =
RPC.service
RPC.Service.post_service
~description: "A failing service"
~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 =

View File

@ -34,8 +34,9 @@ let wrap_tzerror encoding =
module Forge = struct
let block custom_root =
let open Data_encoding in
RPC.service
RPC.Service.post_service
~description: "Forge a block"
~query: RPC.Query.empty
~input:
(merge_objs
(obj6
@ -47,6 +48,7 @@ module Forge = struct
(req "fitness" Fitness.encoding))
Data.Command.encoding)
~output: (obj1 (req "payload" bytes))
~error: Data_encoding.empty
RPC.Path.(custom_root / "helpers" / "forge" / "block")
end

View File

@ -139,17 +139,6 @@ module Service = Resto.MakeService(Data)
(* Compatibility layer, to be removed ASAP. *)
let service ?description ~input ~output path =
Service.post_service
?description
~query: Query.empty
~input
~output
~error: Data_encoding.null
path
type directory_descr = Data_encoding.json_schema Description.directory
let forge_request (type i) (service: (_,_,_,_,i,_,_) Service.t) params body =
let { Service.meth ; path } =
Service.forge_request service params () in

View File

@ -17,15 +17,6 @@ module Service : (module type of struct include Resto.MakeService(Data) end)
(** Compatibility layer, to be removed ASAP. *)
val service:
?description: string ->
input: 'input Data_encoding.t ->
output: 'output Data_encoding.t ->
('prefix, 'params) Path.t ->
([ `POST ], 'prefix, 'params, unit, 'input, 'output, unit) Service.t
type directory_descr = Data_encoding.json_schema Description.directory
val forge_request :
(_ , unit, 'params, unit, 'input, 'output, unit) Service.t ->
'params -> 'input -> MethMap.key * string list * Data_encoding.json

View File

@ -12,10 +12,12 @@ open Data_encoding
module Error = struct
let service =
RPC.service
RPC.Service.post_service
~description: "Schema for all the RPC errors from the shell"
~query: RPC.Query.empty
~input: Data_encoding.empty
~output: Data_encoding.json_schema
~error: Data_encoding.empty
RPC.Path.(root / "errors")
let encoding =
@ -148,61 +150,77 @@ module Blocks = struct
RPC.Path.(root / "blocks" /: blocks_arg )
let info =
RPC.service
RPC.Service.post_service
~description:"All the information about a block."
~query: RPC.Query.empty
~input: (obj1 (dft "operations" bool true))
~output: block_info_encoding
~error: Data_encoding.empty
block_path
let net_id =
RPC.service
RPC.Service.post_service
~description:"Returns the net of the chain in which the block belongs."
~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 =
RPC.service
RPC.Service.post_service
~description:"Returns the block's level."
~query: RPC.Query.empty
~input: empty
~output: (obj1 (req "level" int32))
~error: Data_encoding.empty
RPC.Path.(block_path / "level")
let predecessor =
RPC.service
RPC.Service.post_service
~description:"Returns the previous block's id."
~query: RPC.Query.empty
~input: empty
~output: (obj1 (req "predecessor" Block_hash.encoding))
~error: Data_encoding.empty
RPC.Path.(block_path / "predecessor")
let predecessors =
RPC.service
RPC.Service.post_service
~description:
"...."
~query: RPC.Query.empty
~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 =
RPC.service
RPC.Service.post_service
~description:"Returns the block's id."
~query: RPC.Query.empty
~input: empty
~output: (obj1 (req "hash" Block_hash.encoding))
~error: Data_encoding.empty
RPC.Path.(block_path / "hash")
let fitness =
RPC.service
RPC.Service.post_service
~description:"Returns the block's fitness."
~query: RPC.Query.empty
~input: empty
~output: (obj1 (req "fitness" Fitness.encoding))
~error: Data_encoding.empty
RPC.Path.(block_path / "fitness")
let timestamp =
RPC.service
RPC.Service.post_service
~description:"Returns the block's 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 = {
@ -220,8 +238,9 @@ module Blocks = struct
(dft "monitor" bool false))
let operations =
RPC.service
RPC.Service.post_service
~description:"List the block operations."
~query: RPC.Query.empty
~input: operations_param_encoding
~output: (obj1
(req "operations"
@ -230,20 +249,25 @@ module Blocks = struct
(req "hash" Operation_hash.encoding)
(opt "contents"
(dynamic_size Operation.encoding)))))))
~error: Data_encoding.empty
RPC.Path.(block_path / "operations")
let protocol =
RPC.service
RPC.Service.post_service
~description:"List the block 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 =
RPC.service
RPC.Service.post_service
~description:"Returns the status of the associated 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 =
@ -252,9 +276,10 @@ module Blocks = struct
(obj1 (req "hash" Operation_hash.encoding))
Operation.encoding in
(* TODO: branch_delayed/... *)
RPC.service
RPC.Service.post_service
~description:
"List the not-yet-prevalidated operations."
~query: RPC.Query.empty
~input: empty
~output:
(conv
@ -271,6 +296,7 @@ module Blocks = struct
(dynamic_size
(Preapply_result.encoding Error.encoding))
(obj1 (req "unprocessed" (list (dynamic_size operation_encoding))))))
~error: Data_encoding.empty
RPC.Path.(block_path / "pending_operations")
let proto_path =
@ -312,12 +338,14 @@ module Blocks = struct
(Preapply_result.encoding Error.encoding))))
let preapply =
RPC.service
RPC.Service.post_service
~description:
"Simulate the validation of a block that would contain \
the given operations and return the resulting fitness."
~query: RPC.Query.empty
~input: preapply_param_encoding
~output: (Error.wrap preapply_result_encoding)
~error: Data_encoding.empty
RPC.Path.(block_path / "preapply")
let complete =
@ -325,12 +353,14 @@ module Blocks = struct
let destruct s = Ok s
and construct s = s in
RPC.Arg.make ~name:"prefix" ~destruct ~construct () in
RPC.service
RPC.Service.post_service
~description: "Try to complete a prefix of a Base58Check-encoded data. \
This RPC is actually able to complete hashes of \
block, operations, public_keys and contracts."
~query: RPC.Query.empty
~input: empty
~output: (list string)
~error: Data_encoding.empty
RPC.Path.(block_path / "complete" /: prefix_arg )
type list_param = {
@ -399,26 +429,30 @@ module Blocks = struct
int31)))
let list =
RPC.service
RPC.Service.post_service
~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."
~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 =
RPC.service
RPC.Service.post_service
~description:
"Lists blocks that have been declared invalid along with the errors\
that led to them being declared invalid"
~query: RPC.Query.empty
~input:empty
~output:(Data_encoding.list
(obj3
(req "block" Block_hash.encoding)
(req "level" int32)
(req "errors" Error.encoding)))
~error: Data_encoding.empty
RPC.Path.(root / "invalid_blocks")
end
@ -436,12 +470,14 @@ module Protocols = struct
RPC.Arg.make ~name ~descr ~construct ~destruct ()
let contents =
RPC.service
RPC.Service.post_service
~query: RPC.Query.empty
~input: empty
~output:
(obj1 (req "data"
(describe ~title: "Tezos protocol"
(Protocol.encoding))))
~error: Data_encoding.empty
RPC.Path.(root / "protocols" /: protocols_arg)
type list_param = {
@ -458,7 +494,8 @@ module Protocols = struct
(opt "monitor" bool))
let list =
RPC.service
RPC.Service.post_service
~query: RPC.Query.empty
~input: list_param_encoding
~output:
(obj1
@ -469,6 +506,7 @@ module Protocols = struct
(opt "contents"
(dynamic_size Protocol.encoding)))
)))
~error: Data_encoding.empty
RPC.Path.(root / "protocols")
end
@ -496,31 +534,39 @@ module Network = struct
()
let versions =
RPC.service
RPC.Service.post_service
~description:"Supported network layer versions."
~query: RPC.Query.empty
~input: empty
~output: (list P2p_types.Version.encoding)
~error: Data_encoding.empty
RPC.Path.(root / "network" / "versions")
let stat =
RPC.service
RPC.Service.post_service
~description:"Global network bandwidth statistics in B/s."
~query: RPC.Query.empty
~input: empty
~output: P2p_types.Stat.encoding
~error: Data_encoding.empty
RPC.Path.(root / "network" / "stat")
let events =
RPC.service
RPC.Service.post_service
~description:"Stream of all network events"
~query: RPC.Query.empty
~input: empty
~output: P2p_types.Connection_pool_log_event.encoding
~error: Data_encoding.empty
RPC.Path.(root / "network" / "log")
let connect =
RPC.service
RPC.Service.post_service
~description:"Connect to a peer"
~query: RPC.Query.empty
~input: (obj1 (dft "timeout" float 5.))
~output: (Error.wrap @@ empty)
~error: Data_encoding.empty
RPC.Path.(root / "network" / "connect" /: point_arg)
let monitor_encoding = obj1 (dft "monitor" bool false)
@ -528,23 +574,29 @@ module Network = struct
module Connection = struct
let list =
RPC.service
RPC.Service.post_service
~description:"List the running P2P connection."
~query: RPC.Query.empty
~input: empty
~output: (list P2p_types.Connection_info.encoding)
~error: Data_encoding.empty
RPC.Path.(root / "network" / "connection")
let info =
RPC.service
RPC.Service.post_service
~query: RPC.Query.empty
~input: empty
~output: (option P2p_types.Connection_info.encoding)
~error: Data_encoding.empty
~description:"Details about the current P2P connection to the given peer."
RPC.Path.(root / "network" / "connection" /: peer_id_arg)
let kick =
RPC.service
RPC.Service.post_service
~query: RPC.Query.empty
~input: (obj1 (req "wait" bool))
~output: empty
~error: Data_encoding.empty
~description:"Forced close of the current P2P connection to the given peer."
RPC.Path.(root / "network" / "connection" /: peer_id_arg / "kick")
@ -553,28 +605,34 @@ module Network = struct
module Point = struct
let info =
RPC.service
RPC.Service.post_service
~query: RPC.Query.empty
~input: empty
~output: (option P2p_types.Point_info.encoding)
~error: Data_encoding.empty
~description: "Details about a given `IP:addr`."
RPC.Path.(root / "network" / "point" /: point_arg)
let events =
RPC.service
RPC.Service.post_service
~query: RPC.Query.empty
~input: monitor_encoding
~output: (list P2p_connection_pool_types.Point_info.Event.encoding)
~error: Data_encoding.empty
~description: "Monitor network events related to an `IP:addr`."
RPC.Path.(root / "network" / "point" /: point_arg / "log")
let list =
let filter =
obj1 (dft "filter" (list P2p_types.Point_state.encoding) []) in
RPC.service
RPC.Service.post_service
~query: RPC.Query.empty
~input: filter
~output:
(list (tup2
P2p_types.Point.encoding
P2p_types.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")
@ -584,28 +642,34 @@ module Network = struct
module Peer_id = struct
let info =
RPC.service
RPC.Service.post_service
~query: RPC.Query.empty
~input: empty
~output: (option P2p_types.Peer_info.encoding)
~error: Data_encoding.empty
~description:"Details about a given peer."
RPC.Path.(root / "network" / "peer_id" /: peer_id_arg)
let events =
RPC.service
RPC.Service.post_service
~query: RPC.Query.empty
~input: monitor_encoding
~output: (list P2p_connection_pool_types.Peer_info.Event.encoding)
~error: Data_encoding.empty
~description:"Monitor network events related to a given peer."
RPC.Path.(root / "network" / "peer_id" /: peer_id_arg / "log")
let list =
let filter =
obj1 (dft "filter" (list P2p_types.Peer_state.encoding) []) in
RPC.service
RPC.Service.post_service
~query: RPC.Query.empty
~input: filter
~output:
(list (tup2
P2p_types.Peer_id.encoding
P2p_types.Peer_info.encoding))
~error: Data_encoding.empty
~description:"List the peers the node ever met."
RPC.Path.(root / "network" / "peer_id")
@ -614,10 +678,12 @@ module Network = struct
end
let forge_block_header =
RPC.service
RPC.Service.post_service
~description: "Forge a 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 = {
@ -657,7 +723,7 @@ let inject_block_param =
(list (list (dynamic_size Operation.encoding))))))
let inject_block =
RPC.service
RPC.Service.post_service
~description:
"Inject a block in the node and broadcast it. The `operations` \
embedded in `blockHeader` might be pre-validated using a \
@ -665,14 +731,16 @@ let inject_block =
(e.g. '/blocks/head/context/preapply'). Returns the ID of the \
block. By default, the RPC will wait for the block to be \
validated before answering."
~query: RPC.Query.empty
~input: inject_block_param
~output:
(Error.wrap @@
(obj1 (req "block_hash" Block_hash.encoding)))
~error: Data_encoding.empty
RPC.Path.(root / "inject_block")
let inject_operation =
RPC.service
RPC.Service.post_service
~description:
"Inject an operation in node and broadcast it. Returns the \
ID of the operation. The `signedOperationContents` should be \
@ -681,6 +749,7 @@ let inject_operation =
the operation to be (pre-)validated before answering. See \
RPCs under /blocks/prevalidation for more details on the \
prevalidation context."
~query: RPC.Query.empty
~input:
(obj4
(req "signedOperationContents"
@ -705,12 +774,14 @@ 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 =
RPC.service
RPC.Service.post_service
~description:
"Inject a protocol in node. Returns the ID of the protocol."
~query: RPC.Query.empty
~input:
(obj3
(req "protocol"
@ -732,15 +803,18 @@ 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 =
RPC.service
RPC.Service.post_service
~description:""
~query: RPC.Query.empty
~input: empty
~output: (obj2
(req "block" Block_hash.encoding)
(req "timestamp" Time.encoding))
~error: Data_encoding.empty
RPC.Path.(root / "bootstrapped")
let complete =
@ -748,12 +822,14 @@ let complete =
let destruct s = Ok s
and construct s = s in
RPC.Arg.make ~name:"prefix" ~destruct ~construct () in
RPC.service
RPC.Service.post_service
~description: "Try to complete a prefix of a Base58Check-encoded data. \
This RPC is actually able to complete hashes of \
block and hashes of operations."
~query: RPC.Query.empty
~input: empty
~output: (list string)
~error: Data_encoding.empty
RPC.Path.(root / "complete" /: prefix_arg )
let describe =

View File

@ -293,13 +293,6 @@ end
type 'a directory = 'a Directory.t
val service:
?description: string ->
input: 'input Data_encoding.t ->
output: 'output Data_encoding.t ->
('prefix, 'params) Path.t ->
([ `POST], 'prefix, 'params, unit, 'input, 'output, unit) Service.t
val register:
'prefix directory ->
([ `POST ], 'prefix,