diff --git a/src/node/net/p2p_connection_pool.ml b/src/node/net/p2p_connection_pool.ml index bdb9c330e..48bc4fc40 100644 --- a/src/node/net/p2p_connection_pool.ml +++ b/src/node/net/p2p_connection_pool.ml @@ -1031,8 +1031,13 @@ and swap pool conn current_peer_id new_point = | Error err -> begin pool.latest_accepted_swap <- pool.latest_succesfull_swap ; log pool (Swap_failure { source = source_peer_id }) ; - lwt_log_error "Swap to %a failed: %a" - Point.pp new_point pp_print_error err + match err with + | [ Lwt_utils.Timeout ] -> + lwt_debug "Swap to %a was interupted: %a" + Point.pp new_point pp_print_error err + | _ -> + lwt_log_error "Swap to %a failed: %a" + Point.pp new_point pp_print_error err end let accept pool fd point = diff --git a/src/utils/lwt_utils.ml b/src/utils/lwt_utils.ml index 04055c086..33358b6f0 100644 --- a/src/utils/lwt_utils.ml +++ b/src/utils/lwt_utils.ml @@ -472,6 +472,16 @@ let protect ?on_error ?canceler t = type error += Timeout +let () = + Error_monad.register_error_kind + `Temporary + ~id:"utils.Timeout" + ~title:"Timeout" + ~description:"Timeout" + Data_encoding.unit + (function Timeout -> Some () | _ -> None) + (fun () -> Timeout) + let with_timeout ?(canceler = Canceler.create ()) timeout f = let t = Lwt_unix.sleep timeout in Lwt.choose [