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