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 () ->
|
||||
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 ->
|
||||
| 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)
|
||||
end
|
||||
(* TODO catch other temporary error (e.g. system errors)
|
||||
and do not 'commit' them on disk... *)
|
||||
| Error [Canceled | Unavailable_protocol _] as err ->
|
||||
|
@ -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 =
|
||||
|
Loading…
Reference in New Issue
Block a user