Node: fix error handling in block validator
This commit is contained in:
parent
f600fc57d4
commit
40a26759fc
@ -244,24 +244,20 @@ let on_request
|
|||||||
protect ?canceler begin fun () ->
|
protect ?canceler begin fun () ->
|
||||||
apply_block
|
apply_block
|
||||||
(Distributed_db.chain_state chain_db)
|
(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
|
||||||
end >>= function
|
end >>= function
|
||||||
| Ok result -> begin
|
| Ok block ->
|
||||||
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
|
Protocol_validator.prefetch_and_compile_protocols
|
||||||
bv.protocol_validator
|
bv.protocol_validator
|
||||||
?peer ~timeout:bv.limits.protocol_timeout
|
?peer ~timeout:bv.limits.protocol_timeout
|
||||||
block ;
|
block ;
|
||||||
notify_new_block block ;
|
notify_new_block block ;
|
||||||
return (Ok block)
|
return (Ok block)
|
||||||
end
|
|
||||||
(* TODO catch other temporary error (e.g. system errors)
|
(* TODO catch other temporary error (e.g. system errors)
|
||||||
and do not 'commit' them on disk... *)
|
and do not 'commit' them on disk... *)
|
||||||
| Error [Canceled | Unavailable_protocol _] as err ->
|
| Error [Canceled | Unavailable_protocol _] as err ->
|
||||||
|
@ -276,8 +276,8 @@ let on_error w r st errs =
|
|||||||
|
|
||||||
let on_close w =
|
let on_close w =
|
||||||
let pv = Worker.state w in
|
let pv = Worker.state w in
|
||||||
pv.parameters.notify_termination () ;
|
|
||||||
Distributed_db.disconnect pv.parameters.chain_db pv.peer_id >>= fun () ->
|
Distributed_db.disconnect pv.parameters.chain_db pv.peer_id >>= fun () ->
|
||||||
|
pv.parameters.notify_termination () ;
|
||||||
Lwt.return ()
|
Lwt.return ()
|
||||||
|
|
||||||
let on_launch _ name parameters =
|
let on_launch _ name parameters =
|
||||||
|
Loading…
Reference in New Issue
Block a user