From c1ccea3501a3306d71294d4633e5c4e0a0e30f90 Mon Sep 17 00:00:00 2001 From: OCamlPro-Iguernlala Date: Mon, 21 May 2018 11:25:54 +0200 Subject: [PATCH] P2p: do not send peer swap requests in private mode --- src/lib_p2p/p2p_pool.ml | 5 +++-- src/lib_p2p/p2p_pool.mli | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib_p2p/p2p_pool.ml b/src/lib_p2p/p2p_pool.ml index 4a4bd2fc8..392b7a1af 100644 --- a/src/lib_p2p/p2p_pool.ml +++ b/src/lib_p2p/p2p_pool.ml @@ -1023,8 +1023,7 @@ let accept pool fd point = let send_swap_request pool = match Connection.random pool with - | None -> () - | Some recipient -> + | Some recipient when not pool.config.private_mode -> begin let recipient_peer_id = (Connection.info recipient).peer_id in match Connection.random_lowid ~different_than:recipient pool with | None -> () @@ -1034,6 +1033,8 @@ let send_swap_request pool = Some (Time.now (), proposed_peer_id) ; ignore (P2p_socket.write_now recipient.conn (Swap_request (proposed_point, proposed_peer_id))) + end + | Some _ | None -> () (***************************************************************************) diff --git a/src/lib_p2p/p2p_pool.mli b/src/lib_p2p/p2p_pool.mli index 15e160668..774895d14 100644 --- a/src/lib_p2p/p2p_pool.mli +++ b/src/lib_p2p/p2p_pool.mli @@ -168,6 +168,9 @@ val config : _ pool -> config creation. *) val send_swap_request: ('msg, 'peer_meta,'conn_meta) pool -> unit +(** [send_swap_request pool] given two connected peers pi and pj (pi + <> pj), suggest swap with pi for the peer pj. This behaviour is + disabled in private mode *) (** {2 Pool events} *)