Client: introduce Client_blocks

This commit is contained in:
Grégoire Henry 2017-02-25 13:24:53 +01:00
parent 8f5f5a2106
commit a2f1b6c889
4 changed files with 44 additions and 8 deletions

View File

@ -469,6 +469,7 @@ CLIENT_LIB_IMPLS := \
client/client_aliases.ml \
client/client_keys.ml \
client/client_protocols.ml \
client/client_blocks.ml \
WEBCLIENT_LIB_INTFS := \

View 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

View 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

View File

@ -100,13 +100,6 @@ end = struct
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 =
Client_proto_rpcs.Helpers.Rights.endorsement_rights_for_delegate cctxt
?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
block level ?wait ?force
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_proto_rpcs.Helpers.Forge.Delegate.endorsement cctxt
block