Proto/Alpha: more RPCs
This commit is contained in:
parent
d06fcebd1f
commit
89814a3d4e
@ -16,13 +16,9 @@ let handle_error cctxt = function
|
|||||||
pp_print_error Format.err_formatter exns ;
|
pp_print_error Format.err_formatter exns ;
|
||||||
cctxt.Client_commands.error "%s" "cannot continue"
|
cctxt.Client_commands.error "%s" "cannot continue"
|
||||||
|
|
||||||
type block = [
|
let call_service0 cctxt s block =
|
||||||
| `Genesis
|
Client_rpcs.call_service0 cctxt
|
||||||
| `Head of int | `Prevalidation
|
(s Node_rpc_services.Blocks.proto_path) block
|
||||||
| `Test_head of int | `Test_prevalidation
|
|
||||||
| `Hash of Block_hash.t
|
|
||||||
]
|
|
||||||
|
|
||||||
let call_service1 cctxt s block a1 =
|
let call_service1 cctxt s block a1 =
|
||||||
Client_rpcs.call_service1 cctxt
|
Client_rpcs.call_service1 cctxt
|
||||||
(s Node_rpc_services.Blocks.proto_path) block a1
|
(s Node_rpc_services.Blocks.proto_path) block a1
|
||||||
@ -40,6 +36,18 @@ let call_error_service2 cctxt s block a1 a2 =
|
|||||||
| Ok (Ok v) -> return v
|
| Ok (Ok v) -> return v
|
||||||
| Error _ as err -> Lwt.return err
|
| Error _ as err -> Lwt.return err
|
||||||
|
|
||||||
|
type block = Node_rpc_services.Blocks.block
|
||||||
|
|
||||||
|
let header cctxt block =
|
||||||
|
call_error_service1 cctxt Services.header block ()
|
||||||
|
|
||||||
|
module Header = struct
|
||||||
|
let priority cctxt block =
|
||||||
|
call_error_service1 cctxt Services.Header.priority block ()
|
||||||
|
let seed_nonce_hash cctxt block =
|
||||||
|
call_error_service1 cctxt Services.Header.seed_nonce_hash block ()
|
||||||
|
end
|
||||||
|
|
||||||
module Constants = struct
|
module Constants = struct
|
||||||
let errors cctxt block =
|
let errors cctxt block =
|
||||||
call_service1 cctxt Services.Constants.errors block ()
|
call_service1 cctxt Services.Constants.errors block ()
|
||||||
|
@ -17,6 +17,16 @@ type block = [
|
|||||||
| `Hash of Block_hash.t
|
| `Hash of Block_hash.t
|
||||||
]
|
]
|
||||||
|
|
||||||
|
val header:
|
||||||
|
Client_rpcs.config -> block -> Block_header.t tzresult Lwt.t
|
||||||
|
|
||||||
|
module Header : sig
|
||||||
|
val priority:
|
||||||
|
Client_rpcs.config -> block -> int tzresult Lwt.t
|
||||||
|
val seed_nonce_hash:
|
||||||
|
Client_rpcs.config -> block -> Nonce_hash.t tzresult Lwt.t
|
||||||
|
end
|
||||||
|
|
||||||
module Constants : sig
|
module Constants : sig
|
||||||
val errors:
|
val errors:
|
||||||
Client_rpcs.config ->
|
Client_rpcs.config ->
|
||||||
|
@ -37,12 +37,37 @@ let wrap_tzerror encoding =
|
|||||||
|
|
||||||
let operations custom_root =
|
let operations custom_root =
|
||||||
RPC.service
|
RPC.service
|
||||||
~description: "All the operations of the block (parsed)."
|
~description: "All the operations of the block (fully decoded)."
|
||||||
~input: empty
|
~input: empty
|
||||||
~output: (wrap_tzerror @@
|
~output: (wrap_tzerror @@
|
||||||
(list (list (dynamic_size Operation.encoding))))
|
(list (list (dynamic_size Operation.encoding))))
|
||||||
RPC.Path.(custom_root / "operations")
|
RPC.Path.(custom_root / "operations")
|
||||||
|
|
||||||
|
let header custom_root =
|
||||||
|
RPC.service
|
||||||
|
~description: "The header of the block (fully decoded)."
|
||||||
|
~input: empty
|
||||||
|
~output: (wrap_tzerror Block_header.encoding)
|
||||||
|
RPC.Path.(custom_root / "header")
|
||||||
|
|
||||||
|
module Header = struct
|
||||||
|
|
||||||
|
let priority custom_root =
|
||||||
|
RPC.service
|
||||||
|
~description: "Mining priority of the block."
|
||||||
|
~input: empty
|
||||||
|
~output: (wrap_tzerror uint16)
|
||||||
|
RPC.Path.(custom_root / "header" / "priority")
|
||||||
|
|
||||||
|
let seed_nonce_hash custom_root =
|
||||||
|
RPC.service
|
||||||
|
~description: "Hash of the seed nonce of the block."
|
||||||
|
~input: empty
|
||||||
|
~output: (wrap_tzerror Nonce_hash.encoding)
|
||||||
|
RPC.Path.(custom_root / "header" / "seed_nonce_hash")
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
module Constants = struct
|
module Constants = struct
|
||||||
|
|
||||||
let cycle_length custom_root =
|
let cycle_length custom_root =
|
||||||
|
@ -69,6 +69,24 @@ let () =
|
|||||||
(map2_s (fun x y -> Lwt.return (Operation.parse x y)))
|
(map2_s (fun x y -> Lwt.return (Operation.parse x y)))
|
||||||
operation_hashes operations)
|
operation_hashes operations)
|
||||||
|
|
||||||
|
let () =
|
||||||
|
register0_fullctxt
|
||||||
|
Services.header
|
||||||
|
(fun { block_header } ->
|
||||||
|
Lwt.return (Block_header.parse block_header) >>=? fun block_header ->
|
||||||
|
return block_header) ;
|
||||||
|
register0_fullctxt
|
||||||
|
Services.Header.priority
|
||||||
|
(fun { block_header } ->
|
||||||
|
Lwt.return (Block_header.parse block_header) >>=? fun block_header ->
|
||||||
|
return block_header.proto.priority) ;
|
||||||
|
register0_fullctxt
|
||||||
|
Services.Header.seed_nonce_hash
|
||||||
|
(fun { block_header } ->
|
||||||
|
Lwt.return (Block_header.parse block_header) >>=? fun block_header ->
|
||||||
|
return block_header.proto.seed_nonce_hash)
|
||||||
|
|
||||||
|
|
||||||
(*-- Constants ---------------------------------------------------------------*)
|
(*-- Constants ---------------------------------------------------------------*)
|
||||||
|
|
||||||
let cycle_length ctxt =
|
let cycle_length ctxt =
|
||||||
|
Loading…
Reference in New Issue
Block a user