Baker/Endorser: record baked blocks and endorsement before injecting
This commit is contained in:
parent
3b46f49651
commit
9f52c43cff
@ -49,11 +49,11 @@ let inject_endorsement
|
|||||||
~branch:hash
|
~branch:hash
|
||||||
~level:level
|
~level:level
|
||||||
() >>=? fun bytes ->
|
() >>=? fun bytes ->
|
||||||
|
State.record cctxt pkh level >>=? fun () ->
|
||||||
Shell_services.Chain.chain_id cctxt ~chain () >>=? fun chain_id ->
|
Shell_services.Chain.chain_id cctxt ~chain () >>=? fun chain_id ->
|
||||||
Client_keys.append cctxt
|
Client_keys.append cctxt
|
||||||
src_sk ~watermark:(Endorsement chain_id) bytes >>=? fun signed_bytes ->
|
src_sk ~watermark:(Endorsement chain_id) bytes >>=? fun signed_bytes ->
|
||||||
Shell_services.Injection.operation cctxt ?async ~chain signed_bytes >>=? fun oph ->
|
Shell_services.Injection.operation cctxt ?async ~chain signed_bytes >>=? fun oph ->
|
||||||
State.record cctxt pkh level >>=? fun () ->
|
|
||||||
return oph
|
return oph
|
||||||
|
|
||||||
let check_endorsement cctxt level pkh =
|
let check_endorsement cctxt level pkh =
|
||||||
|
@ -961,6 +961,9 @@ let bake (cctxt : #Proto_alpha.full) state =
|
|||||||
-% t event "double_bake_near_miss"
|
-% t event "double_bake_near_miss"
|
||||||
-% a level_tag level) >>= return
|
-% a level_tag level) >>= return
|
||||||
| false ->
|
| 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
|
inject_block cctxt ~chain ~force:true
|
||||||
~shell_header ~priority ?seed_nonce_hash ~src_sk operations
|
~shell_header ~priority ?seed_nonce_hash ~src_sk operations
|
||||||
|> trace_exn (Failure "Error while injecting block") >>=? fun block_hash ->
|
|> 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
|
-% a operations_tag operations
|
||||||
) >>= fun () ->
|
) >>= 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
|
begin if seed_nonce_hash <> None then
|
||||||
Client_baking_nonces.add cctxt block_hash seed_nonce
|
Client_baking_nonces.add cctxt block_hash seed_nonce
|
||||||
|> trace_exn (Failure "Error while recording nonce")
|
|> trace_exn (Failure "Error while recording nonce")
|
||||||
|
Loading…
Reference in New Issue
Block a user