P2p: export 'P2p_pool.private_node'
'private_node conn' returns 'true' if the node associated with the given connection is in private mode
This commit is contained in:
parent
a70ae26706
commit
cc848fc479
@ -584,6 +584,8 @@ end
|
|||||||
|
|
||||||
module Connection = struct
|
module Connection = struct
|
||||||
|
|
||||||
|
let private_node conn = P2p_socket.private_node conn.conn
|
||||||
|
|
||||||
let fold pool ~init ~f =
|
let fold pool ~init ~f =
|
||||||
Peers.fold_connected pool ~init ~f:begin fun peer_id peer_info acc ->
|
Peers.fold_connected pool ~init ~f:begin fun peer_id peer_info acc ->
|
||||||
match P2p_peer_state.get peer_info with
|
match P2p_peer_state.get peer_info with
|
||||||
@ -597,7 +599,7 @@ module Connection = struct
|
|||||||
let random ?different_than ~no_private pool =
|
let random ?different_than ~no_private pool =
|
||||||
let candidates =
|
let candidates =
|
||||||
fold pool ~init:[] ~f:begin fun _peer conn acc ->
|
fold pool ~init:[] ~f:begin fun _peer conn acc ->
|
||||||
if no_private && (P2p_socket.private_node conn.conn) then
|
if no_private && (private_node conn) then
|
||||||
acc
|
acc
|
||||||
else
|
else
|
||||||
match different_than with
|
match different_than with
|
||||||
@ -613,7 +615,7 @@ module Connection = struct
|
|||||||
let random_lowid ?different_than ~no_private pool =
|
let random_lowid ?different_than ~no_private pool =
|
||||||
let candidates =
|
let candidates =
|
||||||
fold pool ~init:[] ~f:begin fun _peer conn acc ->
|
fold pool ~init:[] ~f:begin fun _peer conn acc ->
|
||||||
if no_private && (P2p_socket.private_node conn.conn) then
|
if no_private && (private_node conn) then
|
||||||
acc
|
acc
|
||||||
else
|
else
|
||||||
match different_than with
|
match different_than with
|
||||||
@ -1031,7 +1033,7 @@ and register_new_point pool _source_peer_id point =
|
|||||||
ignore (register_point pool _source_peer_id point)
|
ignore (register_point pool _source_peer_id point)
|
||||||
|
|
||||||
and list_known_points ?(ignore_private = false) pool conn =
|
and list_known_points ?(ignore_private = false) pool conn =
|
||||||
if P2p_socket.private_node conn.conn then
|
if Connection.private_node conn then
|
||||||
private_node_warn "Private peer (%a) asked other peers addresses"
|
private_node_warn "Private peer (%a) asked other peers addresses"
|
||||||
P2p_peer.Id.pp (P2p_peer_state.Info.peer_id conn.peer_info) >>= fun () ->
|
P2p_peer.Id.pp (P2p_peer_state.Info.peer_id conn.peer_info) >>= fun () ->
|
||||||
Lwt.return_nil
|
Lwt.return_nil
|
||||||
|
@ -267,6 +267,10 @@ module Connection : sig
|
|||||||
P2p_peer.Id.t ->
|
P2p_peer.Id.t ->
|
||||||
('msg, 'peer_meta,'conn_meta) connection option
|
('msg, 'peer_meta,'conn_meta) connection option
|
||||||
|
|
||||||
|
val private_node: ('msg, 'peer_meta,'conn_meta) connection -> bool
|
||||||
|
(** [private_node conn] returns 'true' if the node assocoatied to this
|
||||||
|
connection is in private mode *)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
val on_new_connection:
|
val on_new_connection:
|
||||||
|
Loading…
Reference in New Issue
Block a user