Node: fix error handling in block validator

This commit is contained in:
Benjamin Canou 2018-02-23 18:32:26 +01:00
parent f600fc57d4
commit 40a26759fc
2 changed files with 13 additions and 17 deletions

View File

@ -244,24 +244,20 @@ let on_request
protect ?canceler begin fun () ->
apply_block
(Distributed_db.chain_state chain_db)
pred proto hash header operations
pred proto hash header operations >>=? fun result ->
Distributed_db.commit_block
chain_db hash header operations result >>=? function
| None -> assert false (* should not happen *)
| Some block -> return block
end
end >>= function
| Ok result -> begin
Worker.protect w begin fun () ->
Distributed_db.commit_block
chain_db hash header operations result
end >>=? function
| None ->
assert false (* should not happen *)
| Some block ->
Protocol_validator.prefetch_and_compile_protocols
bv.protocol_validator
?peer ~timeout:bv.limits.protocol_timeout
block ;
notify_new_block block ;
return (Ok block)
end
| Ok block ->
Protocol_validator.prefetch_and_compile_protocols
bv.protocol_validator
?peer ~timeout:bv.limits.protocol_timeout
block ;
notify_new_block block ;
return (Ok block)
(* TODO catch other temporary error (e.g. system errors)
and do not 'commit' them on disk... *)
| Error [Canceled | Unavailable_protocol _] as err ->

View File

@ -276,8 +276,8 @@ let on_error w r st errs =
let on_close w =
let pv = Worker.state w in
pv.parameters.notify_termination () ;
Distributed_db.disconnect pv.parameters.chain_db pv.peer_id >>= fun () ->
pv.parameters.notify_termination () ;
Lwt.return ()
let on_launch _ name parameters =