ligo/src/proto_alpha/lib_delegate/client_baking_revelation.ml

42 lines
1.8 KiB
OCaml
Raw Normal View History

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. *)
(* *)
(**************************************************************************)
open Proto_alpha
2016-09-08 21:13:10 +04:00
let inject_seed_nonce_revelation rpc_config ?(chain = `Main) block ?async nonces =
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 ->
let bytes = Signature.concat bytes Signature.zero in
2018-04-30 21:06:06 +04:00
Shell_services.Injection.operation rpc_config ?async ~chain bytes)
nonces >>=? fun ophs ->
return ophs
2016-09-08 21:13:10 +04:00
let forge_seed_nonce_revelation
(cctxt: #Proto_alpha.full)
?(chain = `Main)
2017-11-23 19:39:33 +04:00
block nonces =
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 ()
| _ ->
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 ()