ligo/src/proto_alpha/lib_client/client_baking_revelation.ml
Grégoire Henry 0bd31b0c38 Client refactor: remove last bits of lib_client_base/client_rpcs.ml
Split between `lib_rpc_http/RPC_client` and
`lib_shell_services/Block_services`.
2018-02-12 16:54:08 +01:00

45 lines
1.8 KiB
OCaml

(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2018. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
open Proto_alpha
open Tezos_context
let inject_seed_nonce_revelation rpc_config block ?async nonces =
let operations =
List.map
(fun (level, nonce) ->
Seed_nonce_revelation { level ; nonce }) nonces in
let block = Block_services.last_baked_block block in
Block_services.info rpc_config block >>=? fun bi ->
Client_proto_rpcs.Helpers.Forge.Anonymous.operations rpc_config
block ~branch:bi.hash operations >>=? fun bytes ->
Shell_services.inject_operation
rpc_config ?async ~net_id:bi.net_id
bytes >>=? fun oph ->
return oph
let forge_seed_nonce_revelation
(cctxt: Client_commands.full_context)
block nonces =
Block_services.hash cctxt block >>=? fun hash ->
match nonces with
| [] ->
cctxt#message "No nonce to reveal for block %a"
Block_hash.pp_short hash >>= fun () ->
return ()
| _ ->
inject_seed_nonce_revelation cctxt block nonces >>=? fun oph ->
cctxt#answer
"Operation successfully injected %d revelation(s) for %a."
(List.length nonces)
Block_hash.pp_short hash >>= fun () ->
cctxt#answer "Operation hash is '%a'."
Operation_hash.pp_short oph >>= fun () ->
return ()