From 40fa79da63e945c654f3053ed24469b082f25af4 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Fri, 8 Sep 2017 17:29:09 +0900 Subject: [PATCH] Remove exception for onion peers Like clearnet peers, they are only returned in server.peers.subscribe if there was a successful connection. --- docs/PEER_DISCOVERY.rst | 9 ++------- server/peers.py | 4 ---- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/docs/PEER_DISCOVERY.rst b/docs/PEER_DISCOVERY.rst index c4c87ea..1d264df 100644 --- a/docs/PEER_DISCOVERY.rst +++ b/docs/PEER_DISCOVERY.rst @@ -53,13 +53,8 @@ The server should craft its response in a way that reduces the effectiveness of sybil attacks and peer spamming. The response should only include peers it has successfully connected -to recently. If Tor routing is not available, so their existence -cannot be verified, the response should include some hard-coded onion -peers so that clients always have a choice of onion servers. - -Only reporting recent good peers ensures that those that have gone -offline will not be passed around for long (ignoring for hard-coded -onion peer exception). +to recently. Only reporting recent good peers ensures that those that +have gone offline will not be passed around for long. In ElectrumX, "recently" is taken to be the last 24 hours. Only one peer from each IPv4/16 netmask is returned, and the number of onion diff --git a/server/peers.py b/server/peers.py index abc38ad..3cce161 100644 --- a/server/peers.py +++ b/server/peers.py @@ -259,7 +259,6 @@ class PeerManager(util.LoggedClass): # IP address that was connected to. Adding a peer will evict # any other peers with the same host name or IP address. self.peers = set() - self.onion_peers = [] self.permit_onion_peer_time = time.time() self.proxy = SocksProxy(env.tor_proxy_host, env.tor_proxy_port, loop=self.loop) @@ -417,7 +416,6 @@ class PeerManager(util.LoggedClass): peers.update(bucket_peers[:2]) # Add up to 20% onion peers (but up to 10 is OK anyway) - onion_peers = onion_peers or self.onion_peers random.shuffle(onion_peers) max_onion = 50 if is_tor else max(10, len(peers) // 4) @@ -460,8 +458,6 @@ class PeerManager(util.LoggedClass): '''Import hard-coded peers from a file or the coin defaults.''' self.add_peers(self.myselves) coin_peers = self.env.coin.PEERS - self.onion_peers = [Peer.from_real_name(rn, 'coins.py') - for rn in coin_peers if '.onion ' in rn] # If we don't have many peers in the peers file, add # hard-coded ones