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
|
|
|
|
2018-04-16 02:44:24 +04:00
|
|
|
let inject_seed_nonce_revelation rpc_config ?(chain = `Main) block ?async nonces =
|
2018-04-22 16:40:44 +04:00
|
|
|
Alpha_block_services.hash rpc_config ~chain ~block () >>=? fun branch ->
|
2018-04-30 21:06:06 +04:00
|
|
|
map_p
|
|
|
|
(fun (level, nonce) ->
|
|
|
|
Alpha_services.Forge.seed_nonce_revelation rpc_config
|
|
|
|
(chain, block) ~branch ~level ~nonce () >>=? fun bytes ->
|
|
|
|
Shell_services.Injection.operation rpc_config ?async ~chain bytes)
|
|
|
|
nonces >>=? fun ophs ->
|
|
|
|
return ophs
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-14 13:33:34 +04:00
|
|
|
let forge_seed_nonce_revelation
|
2018-02-16 21:10:18 +04:00
|
|
|
(cctxt: #Proto_alpha.full)
|
2018-04-16 02:44:24 +04:00
|
|
|
?(chain = `Main)
|
2017-11-23 19:39:33 +04:00
|
|
|
block nonces =
|
2018-04-22 16:40:44 +04:00
|
|
|
Shell_services.Blocks.hash cctxt ~chain ~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 ()
|
|
|
|
| _ ->
|
2018-04-16 02:44:24 +04:00
|
|
|
inject_seed_nonce_revelation cctxt ~chain 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 () ->
|
2018-04-30 21:06:06 +04:00
|
|
|
cctxt#answer "@[<v 2>Operation hash are:@ %a@]"
|
|
|
|
(Format.pp_print_list Operation_hash.pp_short) oph >>= fun () ->
|
2016-09-08 21:13:10 +04:00
|
|
|
return ()
|