Baker/Endorser: record baked blocks and endorsement before injecting

This commit is contained in:
Vincent Botbol 2018-11-23 23:02:27 +01:00 committed by Pierre Boutillier
parent 3b46f49651
commit 9f52c43cff
No known key found for this signature in database
GPG Key ID: C2F73508B56A193C
2 changed files with 4 additions and 3 deletions

View File

@ -49,11 +49,11 @@ let inject_endorsement
~branch:hash
~level:level
() >>=? fun bytes ->
State.record cctxt pkh level >>=? fun () ->
Shell_services.Chain.chain_id cctxt ~chain () >>=? fun chain_id ->
Client_keys.append cctxt
src_sk ~watermark:(Endorsement chain_id) bytes >>=? fun signed_bytes ->
Shell_services.Injection.operation cctxt ?async ~chain signed_bytes >>=? fun oph ->
State.record cctxt pkh level >>=? fun () ->
return oph
let check_endorsement cctxt level pkh =

View File

@ -961,6 +961,9 @@ let bake (cctxt : #Proto_alpha.full) state =
-% t event "double_bake_near_miss"
-% a level_tag level) >>= return
| false ->
(* Record baked blocks to prevent double baking and nonces to reveal later *)
State.record cctxt src_pkh level >>=? fun () ->
inject_block cctxt ~chain ~force:true
~shell_header ~priority ?seed_nonce_hash ~src_sk operations
|> trace_exn (Failure "Error while injecting block") >>=? fun block_hash ->
@ -977,8 +980,6 @@ let bake (cctxt : #Proto_alpha.full) state =
-% a operations_tag operations
) >>= fun () ->
(* Record baked blocks to prevent double baking and nonces to reveal later *)
State.record cctxt src_pkh level >>=? fun () ->
begin if seed_nonce_hash <> None then
Client_baking_nonces.add cctxt block_hash seed_nonce
|> trace_exn (Failure "Error while recording nonce")