2016-09-08 21:13:10 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
2018-02-06 00:17:03 +04:00
|
|
|
(* Copyright (c) 2014 - 2018. *)
|
2016-09-08 21:13:10 +04:00
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
2018-01-29 04:06:47 +04:00
|
|
|
open Proto_alpha
|
2016-09-08 21:13:10 +04:00
|
|
|
open Tezos_context
|
|
|
|
|
2017-11-23 19:39:33 +04:00
|
|
|
let inject_seed_nonce_revelation rpc_config block ?async nonces =
|
2016-09-08 21:13:10 +04:00
|
|
|
let operations =
|
|
|
|
List.map
|
|
|
|
(fun (level, nonce) ->
|
|
|
|
Seed_nonce_revelation { level ; nonce }) nonces in
|
2018-02-11 22:17:39 +04:00
|
|
|
let block = Block_services.last_baked_block block in
|
2018-02-08 13:51:02 +04:00
|
|
|
Block_services.info rpc_config block >>=? fun bi ->
|
2017-04-20 10:49:14 +04:00
|
|
|
Client_proto_rpcs.Helpers.Forge.Anonymous.operations rpc_config
|
2017-11-14 05:41:37 +04:00
|
|
|
block ~branch:bi.hash operations >>=? fun bytes ->
|
2018-02-08 13:51:02 +04:00
|
|
|
Shell_services.inject_operation
|
2017-11-23 19:39:33 +04:00
|
|
|
rpc_config ?async ~net_id:bi.net_id
|
2017-11-14 05:41:37 +04:00
|
|
|
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
|
2018-02-11 22:17:39 +04:00
|
|
|
(cctxt: #Client_commands.full_context)
|
2017-11-23 19:39:33 +04:00
|
|
|
block nonces =
|
2018-02-08 13:51:02 +04:00
|
|
|
Block_services.hash cctxt block >>=? fun hash ->
|
2016-09-08 21:13:10 +04:00
|
|
|
match nonces with
|
|
|
|
| [] ->
|
2017-11-07 20:38:11 +04:00
|
|
|
cctxt#message "No nonce to reveal for block %a"
|
2017-02-14 15:24:56 +04:00
|
|
|
Block_hash.pp_short hash >>= fun () ->
|
2016-09-08 21:13:10 +04:00
|
|
|
return ()
|
|
|
|
| _ ->
|
2017-11-23 19:39:33 +04:00
|
|
|
inject_seed_nonce_revelation cctxt block nonces >>=? fun oph ->
|
2017-11-07 20:38:11 +04:00
|
|
|
cctxt#answer
|
2017-02-14 15:24:56 +04:00
|
|
|
"Operation successfully injected %d revelation(s) for %a."
|
|
|
|
(List.length nonces)
|
|
|
|
Block_hash.pp_short hash >>= fun () ->
|
2017-11-07 20:38:11 +04:00
|
|
|
cctxt#answer "Operation hash is '%a'."
|
2017-02-14 15:24:56 +04:00
|
|
|
Operation_hash.pp_short oph >>= fun () ->
|
2016-09-08 21:13:10 +04:00
|
|
|
return ()
|