Client: introduce Client_blocks
This commit is contained in:
parent
8f5f5a2106
commit
a2f1b6c889
@ -469,6 +469,7 @@ CLIENT_LIB_IMPLS := \
|
|||||||
client/client_aliases.ml \
|
client/client_aliases.ml \
|
||||||
client/client_keys.ml \
|
client/client_keys.ml \
|
||||||
client/client_protocols.ml \
|
client/client_protocols.ml \
|
||||||
|
client/client_blocks.ml \
|
||||||
|
|
||||||
WEBCLIENT_LIB_INTFS := \
|
WEBCLIENT_LIB_INTFS := \
|
||||||
|
|
||||||
|
24
src/client/client_blocks.ml
Normal file
24
src/client/client_blocks.ml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
(**************************************************************************)
|
||||||
|
(* *)
|
||||||
|
(* Copyright (c) 2014 - 2016. *)
|
||||||
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
||||||
|
(* *)
|
||||||
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
||||||
|
(* *)
|
||||||
|
(**************************************************************************)
|
||||||
|
|
||||||
|
let get_block_hash cctxt = function
|
||||||
|
| `Hash hash -> Lwt.return hash
|
||||||
|
| `Genesis | `Head _ | `Test_head _ as block ->
|
||||||
|
Client_node_rpcs.Blocks.hash cctxt block
|
||||||
|
| `Prevalidation -> Client_node_rpcs.Blocks.hash cctxt (`Head 0)
|
||||||
|
| `Test_prevalidation -> Client_node_rpcs.Blocks.hash cctxt (`Test_head 0)
|
||||||
|
|
||||||
|
|
||||||
|
let get_block_info cctxt block =
|
||||||
|
let block =
|
||||||
|
match block with
|
||||||
|
| `Prevalidation -> `Head 0
|
||||||
|
| `Test_prevalidation -> `Test_head 0
|
||||||
|
| b -> b in
|
||||||
|
Client_node_rpcs.Blocks.info cctxt block
|
18
src/client/client_blocks.mli
Normal file
18
src/client/client_blocks.mli
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
(**************************************************************************)
|
||||||
|
(* *)
|
||||||
|
(* Copyright (c) 2014 - 2016. *)
|
||||||
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
||||||
|
(* *)
|
||||||
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
||||||
|
(* *)
|
||||||
|
(**************************************************************************)
|
||||||
|
|
||||||
|
val get_block_hash:
|
||||||
|
Client_commands.context ->
|
||||||
|
Client_node_rpcs.Blocks.block ->
|
||||||
|
Block_hash.Table.key Lwt.t
|
||||||
|
|
||||||
|
val get_block_info:
|
||||||
|
Client_commands.context ->
|
||||||
|
Client_node_rpcs.Blocks.block ->
|
||||||
|
Client_node_rpcs.Blocks.block_info Lwt.t
|
@ -100,13 +100,6 @@ end = struct
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
let get_block_hash cctxt = function
|
|
||||||
| `Hash hash -> Lwt.return hash
|
|
||||||
| `Genesis | `Head _ | `Test_head _ as block ->
|
|
||||||
Client_node_rpcs.Blocks.hash cctxt block
|
|
||||||
| `Prevalidation -> Client_node_rpcs.Blocks.hash cctxt (`Head 0)
|
|
||||||
| `Test_prevalidation -> Client_node_rpcs.Blocks.hash cctxt (`Test_head 0)
|
|
||||||
|
|
||||||
let get_signing_slots cctxt ?max_priority block delegate level =
|
let get_signing_slots cctxt ?max_priority block delegate level =
|
||||||
Client_proto_rpcs.Helpers.Rights.endorsement_rights_for_delegate cctxt
|
Client_proto_rpcs.Helpers.Rights.endorsement_rights_for_delegate cctxt
|
||||||
?max_priority ~first_level:level ~last_level:level
|
?max_priority ~first_level:level ~last_level:level
|
||||||
@ -119,7 +112,7 @@ let get_signing_slots cctxt ?max_priority block delegate level =
|
|||||||
let inject_endorsement cctxt
|
let inject_endorsement cctxt
|
||||||
block level ?wait ?force
|
block level ?wait ?force
|
||||||
src_sk source slot =
|
src_sk source slot =
|
||||||
get_block_hash cctxt block >>= fun block_hash ->
|
Client_blocks.get_block_hash cctxt block >>= fun block_hash ->
|
||||||
Client_node_rpcs.Blocks.net cctxt block >>= fun net ->
|
Client_node_rpcs.Blocks.net cctxt block >>= fun net ->
|
||||||
Client_proto_rpcs.Helpers.Forge.Delegate.endorsement cctxt
|
Client_proto_rpcs.Helpers.Forge.Delegate.endorsement cctxt
|
||||||
block
|
block
|
||||||
|
Loading…
Reference in New Issue
Block a user