2016-09-08 21:13:10 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
2017-11-14 03:36:14 +04:00
|
|
|
(* Copyright (c) 2014 - 2017. *)
|
2016-09-08 21:13:10 +04:00
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
open Tezos_context
|
|
|
|
|
2017-04-20 10:49:14 +04:00
|
|
|
let inject_seed_nonce_revelation rpc_config block ?force ?async nonces =
|
2016-09-08 21:13:10 +04:00
|
|
|
let operations =
|
|
|
|
List.map
|
|
|
|
(fun (level, nonce) ->
|
|
|
|
Seed_nonce_revelation { level ; nonce }) nonces in
|
2017-04-20 10:49:14 +04:00
|
|
|
let block = Client_rpcs.last_mined_block block in
|
|
|
|
Client_node_rpcs.Blocks.info rpc_config block >>=? fun bi ->
|
|
|
|
Client_proto_rpcs.Helpers.Forge.Anonymous.operations rpc_config
|
2017-11-14 05:41:37 +04:00
|
|
|
block ~branch:bi.hash operations >>=? fun bytes ->
|
|
|
|
Client_node_rpcs.inject_operation
|
|
|
|
rpc_config ?force ?async ~net_id:bi.net_id
|
|
|
|
bytes >>=? fun oph ->
|
2016-09-08 21:13:10 +04:00
|
|
|
return oph
|
|
|
|
|
2017-02-14 13:33:34 +04:00
|
|
|
let forge_seed_nonce_revelation
|
|
|
|
(cctxt: Client_commands.context)
|
|
|
|
block ?(force = false) nonces =
|
2017-04-05 01:35:41 +04:00
|
|
|
Client_node_rpcs.Blocks.hash cctxt.rpc_config block >>=? fun hash ->
|
2016-09-08 21:13:10 +04:00
|
|
|
match nonces with
|
|
|
|
| [] ->
|
2017-02-14 15:24:56 +04:00
|
|
|
cctxt.message "No nonce to reveal for block %a"
|
|
|
|
Block_hash.pp_short hash >>= fun () ->
|
2016-09-08 21:13:10 +04:00
|
|
|
return ()
|
|
|
|
| _ ->
|
2017-04-05 01:35:41 +04:00
|
|
|
inject_seed_nonce_revelation cctxt.rpc_config block ~force nonces >>=? fun oph ->
|
2017-02-14 15:24:56 +04:00
|
|
|
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 () ->
|
2016-09-08 21:13:10 +04:00
|
|
|
return ()
|