P2p: slighty less verbose debug
This commit is contained in:
parent
5456824960
commit
26c08672dd
@ -220,8 +220,8 @@ module Real = struct
|
||||
let recv _net conn =
|
||||
P2p_pool.read conn >>=? fun msg ->
|
||||
lwt_debug "message read from %a"
|
||||
P2p_connection.Info.pp
|
||||
(P2p_pool.Connection.info conn) >>= fun () ->
|
||||
P2p_peer.Id.pp
|
||||
(P2p_pool.Connection.info conn).peer_id >>= fun () ->
|
||||
return msg
|
||||
|
||||
let rec recv_any net () =
|
||||
@ -242,13 +242,13 @@ module Real = struct
|
||||
P2p_pool.read conn >>= function
|
||||
| Ok msg ->
|
||||
lwt_debug "message read from %a"
|
||||
P2p_connection.Info.pp
|
||||
(P2p_pool.Connection.info conn) >>= fun () ->
|
||||
P2p_peer.Id.pp
|
||||
(P2p_pool.Connection.info conn).peer_id >>= fun () ->
|
||||
Lwt.return (conn, msg)
|
||||
| Error _ ->
|
||||
lwt_debug "error reading message from %a"
|
||||
P2p_connection.Info.pp
|
||||
(P2p_pool.Connection.info conn) >>= fun () ->
|
||||
P2p_peer.Id.pp
|
||||
(P2p_pool.Connection.info conn).peer_id >>= fun () ->
|
||||
Lwt_unix.yield () >>= fun () ->
|
||||
recv_any net ()
|
||||
|
||||
@ -256,13 +256,13 @@ module Real = struct
|
||||
P2p_pool.write conn m >>= function
|
||||
| Ok () ->
|
||||
lwt_debug "message sent to %a"
|
||||
P2p_connection.Info.pp
|
||||
(P2p_pool.Connection.info conn) >>= fun () ->
|
||||
P2p_peer.Id.pp
|
||||
(P2p_pool.Connection.info conn).peer_id >>= fun () ->
|
||||
return ()
|
||||
| Error err ->
|
||||
lwt_debug "error sending message from %a: %a"
|
||||
P2p_connection.Info.pp
|
||||
(P2p_pool.Connection.info conn)
|
||||
P2p_peer.Id.pp
|
||||
(P2p_pool.Connection.info conn).peer_id
|
||||
pp_print_error err >>= fun () ->
|
||||
Lwt.return (Error err)
|
||||
|
||||
@ -270,13 +270,13 @@ module Real = struct
|
||||
match P2p_pool.write_now conn v with
|
||||
| Ok v ->
|
||||
debug "message trysent to %a"
|
||||
P2p_connection.Info.pp
|
||||
(P2p_pool.Connection.info conn) ;
|
||||
P2p_peer.Id.pp
|
||||
(P2p_pool.Connection.info conn).peer_id ;
|
||||
v
|
||||
| Error err ->
|
||||
debug "error trysending message to %a@ %a"
|
||||
P2p_connection.Info.pp
|
||||
(P2p_pool.Connection.info conn)
|
||||
P2p_peer.Id.pp
|
||||
(P2p_pool.Connection.info conn).peer_id
|
||||
pp_print_error err ;
|
||||
false
|
||||
|
||||
|
@ -377,9 +377,10 @@ let register_peer pool peer_id =
|
||||
|
||||
let read { messages ; conn } =
|
||||
Lwt.catch
|
||||
(fun () -> Lwt_pipe.pop messages >>= fun (s, msg) ->
|
||||
(fun () ->
|
||||
Lwt_pipe.pop messages >>= fun (s, msg) ->
|
||||
lwt_debug "%d bytes message popped from queue %a\027[0m"
|
||||
s P2p_connection.Info.pp (P2p_socket.info conn) >>= fun () ->
|
||||
s P2p_peer.Id.pp (P2p_socket.info conn).peer_id >>= fun () ->
|
||||
return msg)
|
||||
(fun _ (* Closed *) -> fail P2p_errors.Connection_closed)
|
||||
|
||||
@ -764,7 +765,7 @@ and authenticate pool ?point_info canceler fd point =
|
||||
(* Authentication correct! *)
|
||||
lwt_debug "authenticate: %a -> auth %a"
|
||||
P2p_point.Id.pp point
|
||||
P2p_connection.Info.pp info >>= fun () ->
|
||||
P2p_peer.Id.pp info.peer_id >>= fun () ->
|
||||
fail_when (Peers.banned pool info.peer_id)
|
||||
(P2p_errors.Peer_banned info.peer_id) >>=? fun () ->
|
||||
let remote_point_info =
|
||||
@ -818,7 +819,7 @@ and authenticate pool ?point_info canceler fd point =
|
||||
P2p_peer_state.set_accepted peer_info info.id_point canceler ;
|
||||
lwt_debug "authenticate: %a -> accept %a"
|
||||
P2p_point.Id.pp point
|
||||
P2p_connection.Info.pp info >>= fun () ->
|
||||
P2p_peer.Id.pp info.peer_id >>= fun () ->
|
||||
protect ~canceler begin fun () ->
|
||||
P2p_socket.accept
|
||||
?incoming_message_queue_size:pool.config.incoming_message_queue_size
|
||||
@ -830,7 +831,7 @@ and authenticate pool ?point_info canceler fd point =
|
||||
pool.encoding >>=? fun conn ->
|
||||
lwt_debug "authenticate: %a -> Connected %a"
|
||||
P2p_point.Id.pp point
|
||||
P2p_connection.Info.pp info >>= fun () ->
|
||||
P2p_peer.Id.pp info.peer_id >>= fun () ->
|
||||
return conn
|
||||
end ~on_error: begin fun err ->
|
||||
if incoming then
|
||||
@ -838,7 +839,7 @@ and authenticate pool ?point_info canceler fd point =
|
||||
(Request_rejected (point, Some (info.id_point, info.peer_id))) ;
|
||||
lwt_debug "authenticate: %a -> rejected %a"
|
||||
P2p_point.Id.pp point
|
||||
P2p_connection.Info.pp info >>= fun () ->
|
||||
P2p_peer.Id.pp info.peer_id >>= fun () ->
|
||||
Option.iter connection_point_info
|
||||
~f:P2p_point_state.set_disconnected ;
|
||||
P2p_peer_state.set_disconnected peer_info ;
|
||||
@ -857,7 +858,7 @@ and authenticate pool ?point_info canceler fd point =
|
||||
log pool (Rejecting_request (point, info.id_point, info.peer_id)) ;
|
||||
lwt_debug "authenticate: %a -> kick %a point: %B peer_id: %B"
|
||||
P2p_point.Id.pp point
|
||||
P2p_connection.Info.pp info
|
||||
P2p_peer.Id.pp info.peer_id
|
||||
acceptable_point acceptable_peer_id >>= fun () ->
|
||||
P2p_socket.kick auth_fd >>= fun () ->
|
||||
if not incoming then begin
|
||||
|
@ -292,7 +292,7 @@ module Reader = struct
|
||||
end >>=? fun buf ->
|
||||
lwt_debug
|
||||
"reading %d bytes from %a"
|
||||
(MBytes.length buf) P2p_connection.Info.pp st.conn.info >>= fun () ->
|
||||
(MBytes.length buf) P2p_peer.Id.pp st.conn.info.peer_id >>= fun () ->
|
||||
loop (decode_next_buf buf) in
|
||||
loop (Data_encoding.Binary.read_stream ?init st.encoding)
|
||||
|
||||
@ -319,7 +319,7 @@ module Reader = struct
|
||||
Lwt.return_unit
|
||||
| Error [Canceled | Exn Lwt_pipe.Closed] ->
|
||||
lwt_debug "connection closed to %a"
|
||||
P2p_connection.Info.pp st.conn.info >>= fun () ->
|
||||
P2p_peer.Id.pp st.conn.info.peer_id >>= fun () ->
|
||||
Lwt.return_unit
|
||||
| Error _ as err ->
|
||||
Lwt_pipe.safe_push_now st.messages err ;
|
||||
@ -372,7 +372,7 @@ module Writer = struct
|
||||
Crypto.write_chunk st.conn.fd st.conn.cryptobox_data buf
|
||||
end >>=? fun () ->
|
||||
lwt_debug "writing %d bytes to %a"
|
||||
(MBytes.length buf) P2p_connection.Info.pp st.conn.info >>= fun () ->
|
||||
(MBytes.length buf) P2p_peer.Id.pp st.conn.info.peer_id >>= fun () ->
|
||||
loop l in
|
||||
loop buf
|
||||
|
||||
@ -390,12 +390,12 @@ module Writer = struct
|
||||
end >>= function
|
||||
| Error [Canceled | Exn Lwt_pipe.Closed] ->
|
||||
lwt_debug "connection closed to %a"
|
||||
P2p_connection.Info.pp st.conn.info >>= fun () ->
|
||||
P2p_peer.Id.pp st.conn.info.peer_id >>= fun () ->
|
||||
Lwt.return_unit
|
||||
| Error err ->
|
||||
lwt_log_error
|
||||
"@[<v 2>error writing to %a@ %a@]"
|
||||
P2p_connection.Info.pp st.conn.info pp_print_error err >>= fun () ->
|
||||
P2p_peer.Id.pp st.conn.info.peer_id pp_print_error err >>= fun () ->
|
||||
Lwt_canceler.cancel st.canceler >>= fun () ->
|
||||
Lwt.return_unit
|
||||
| Ok (buf, wakener) ->
|
||||
@ -412,17 +412,17 @@ module Writer = struct
|
||||
match err with
|
||||
| [ Canceled | Exn Lwt_pipe.Closed ] ->
|
||||
lwt_debug "connection closed to %a"
|
||||
P2p_connection.Info.pp st.conn.info >>= fun () ->
|
||||
P2p_peer.Id.pp st.conn.info.peer_id >>= fun () ->
|
||||
Lwt.return_unit
|
||||
| [ P2p_errors.Connection_closed ] ->
|
||||
lwt_debug "connection closed to %a"
|
||||
P2p_connection.Info.pp st.conn.info >>= fun () ->
|
||||
P2p_peer.Id.pp st.conn.info.peer_id >>= fun () ->
|
||||
Lwt_canceler.cancel st.canceler >>= fun () ->
|
||||
Lwt.return_unit
|
||||
| err ->
|
||||
lwt_log_error
|
||||
"@[<v 2>error writing to %a@ %a@]"
|
||||
P2p_connection.Info.pp st.conn.info
|
||||
P2p_peer.Id.pp st.conn.info.peer_id
|
||||
pp_print_error err >>= fun () ->
|
||||
Lwt_canceler.cancel st.canceler >>= fun () ->
|
||||
Lwt.return_unit
|
||||
|
Loading…
Reference in New Issue
Block a user