Node: Cleanup a few error messages.

This commit is contained in:
Benjamin Canou 2017-11-28 15:07:34 +01:00
parent 606c6e55e4
commit e91f5bc588
3 changed files with 29 additions and 5 deletions

View File

@ -768,12 +768,20 @@ and authenticate pool ?point_info canceler fd point =
?listening_port:pool.config.listening_port ?listening_port:pool.config.listening_port
pool.config.identity pool.message_config.versions pool.config.identity pool.message_config.versions
end ~on_error: begin fun err -> end ~on_error: begin fun err ->
(* Authentication incorrect! *)
(* TODO do something when the error is Not_enough_proof_of_work ?? *) (* TODO do something when the error is Not_enough_proof_of_work ?? *)
begin match err with
| [ Lwt_utils.Canceled ] ->
(* Currently only on time out *)
lwt_debug "authenticate: %a%s -> canceled"
Point.pp point
(if incoming then " incoming" else "")
| err ->
(* Authentication incorrect! *)
lwt_debug "@[authenticate: %a%s -> failed@ %a@]" lwt_debug "@[authenticate: %a%s -> failed@ %a@]"
Point.pp point Point.pp point
(if incoming then " incoming" else "") (if incoming then " incoming" else "")
pp_print_error err >>= fun () -> pp_print_error err
end >>= fun () ->
may_register_my_id_point pool err ; may_register_my_id_point pool err ;
log pool (Authentication_failed point) ; log pool (Authentication_failed point) ;
if incoming then if incoming then

View File

@ -90,6 +90,12 @@ let headers_fetch_worker_loop pipeline =
Lwt.return_unit Lwt.return_unit
| Error [Exn Lwt.Canceled | Lwt_utils.Canceled | Exn Lwt_pipe.Closed] -> | Error [Exn Lwt.Canceled | Lwt_utils.Canceled | Exn Lwt_pipe.Closed] ->
Lwt.return_unit Lwt.return_unit
| Error [ Distributed_db.Block_header.Timeout bh ] ->
lwt_log_info "request for header %a from peer %a timed out."
Block_hash.pp_short bh
P2p.Peer_id.pp_short pipeline.peer_id >>= fun () ->
Canceler.cancel pipeline.canceler >>= fun () ->
Lwt.return_unit
| Error err -> | Error err ->
pipeline.errors <- pipeline.errors @ err ; pipeline.errors <- pipeline.errors @ err ;
lwt_log_error "@[Unexpected error (headers fetch):@ %a@]" lwt_log_error "@[Unexpected error (headers fetch):@ %a@]"
@ -128,6 +134,12 @@ let rec operations_fetch_worker_loop pipeline =
| Error [Exn Lwt.Canceled | Lwt_utils.Canceled | Exn Lwt_pipe.Closed] -> | Error [Exn Lwt.Canceled | Lwt_utils.Canceled | Exn Lwt_pipe.Closed] ->
Lwt_pipe.close pipeline.fetched_blocks ; Lwt_pipe.close pipeline.fetched_blocks ;
Lwt.return_unit Lwt.return_unit
| Error [ Distributed_db.Operations.Timeout (bh, n) ] ->
lwt_log_info "request for operations %a:%d from peer %a timed out."
Block_hash.pp_short bh n
P2p.Peer_id.pp_short pipeline.peer_id >>= fun () ->
Canceler.cancel pipeline.canceler >>= fun () ->
Lwt.return_unit
| Error err -> | Error err ->
pipeline.errors <- pipeline.errors @ err ; pipeline.errors <- pipeline.errors @ err ;
lwt_log_error "@[Unexpected error (operations fetch):@ %a@]" lwt_log_error "@[Unexpected error (operations fetch):@ %a@]"

View File

@ -198,6 +198,10 @@ and worker_loop nv =
if if
Fitness.(block_header.shell.fitness <= head_header.shell.fitness) Fitness.(block_header.shell.fitness <= head_header.shell.fitness)
then then
lwt_log_info "current head is better than %a %a %a, we do not switch"
Block_hash.pp_short block_hash
Fitness.pp block_header.shell.fitness
Time.pp_hum block_header.shell.timestamp >>= fun () ->
return () return ()
else begin else begin
Chain.set_head nv.net_state block >>= fun previous -> Chain.set_head nv.net_state block >>= fun previous ->