From 6b6d357a139c118ca02a7e301ad78ee003929188 Mon Sep 17 00:00:00 2001 From: Kevin F Date: Tue, 14 Jun 2022 11:01:07 -0500 Subject: [PATCH] Small gossip fixes --- src/filepaths/__init__.py | 1 - src/gossip/client/storeblocks.py | 2 +- src/utils/createdirs.py | 2 +- static-data/default-plugins/tor/announce.py | 7 ++++--- tests/gossip-unittests/test_client_peer_exchange.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/filepaths/__init__.py b/src/filepaths/__init__.py index f81a5c3d..ea541f40 100644 --- a/src/filepaths/__init__.py +++ b/src/filepaths/__init__.py @@ -8,7 +8,6 @@ app_root = os.path.dirname(os.path.realpath(__file__)) + '/../../' gossip_server_socket_file = home + 'gossip-server.sock' usage_file = home + 'disk-usage.txt' -block_data_location = home + 'blocks/' contacts_location = home + 'contacts/' public_API_host_file = home + 'public-host.txt' private_API_host_file = home + 'private-host.txt' diff --git a/src/gossip/client/storeblocks.py b/src/gossip/client/storeblocks.py index 095b9d4c..4eda747b 100644 --- a/src/gossip/client/storeblocks.py +++ b/src/gossip/client/storeblocks.py @@ -33,7 +33,7 @@ def store_blocks(dandelion_phase: 'DandelionPhase'): and dandelion_phase.remaining_time() > 1: try: blockdb.add_block_to_db( - new_queue.get(timeout=dandelion_phase.remaining_time()) + new_queue.get(timeout=dandelion_phase.remaining_time() + 1) ) except Empty: pass diff --git a/src/utils/createdirs.py b/src/utils/createdirs.py index 8462faa5..9b08b395 100644 --- a/src/utils/createdirs.py +++ b/src/utils/createdirs.py @@ -31,7 +31,7 @@ def create_dirs(): """Create onionr data-related directories in order of the hardcoded list below, then trigger creation of DBs""" - gen_dirs = [home, filepaths.block_data_location, + gen_dirs = [home, filepaths.contacts_location, filepaths.export_location] for path in gen_dirs: diff --git a/static-data/default-plugins/tor/announce.py b/static-data/default-plugins/tor/announce.py index bbf3f3c5..fdea5859 100644 --- a/static-data/default-plugins/tor/announce.py +++ b/static-data/default-plugins/tor/announce.py @@ -8,18 +8,19 @@ from torpeer import TorPeer def on_announce_rec(api, data=None): socks_address, socks_port = get_socks()[0] - announced = data['address'] + announced: str = data['address'] try: announced = announced.decode('utf-8') except AttributeError: pass + announced = announced.strip() - if announced == config.get('tor.transport_address'): + if announced.removesuffix('.onion') == config.get( + 'tor.transport_address', '').removesuffix('.onion'): logger.warn( "Received announcement for our own node, which shouldn't happen") return - announced = announced.strip() if not announced.endswith('.onion'): announced += '.onion' diff --git a/tests/gossip-unittests/test_client_peer_exchange.py b/tests/gossip-unittests/test_client_peer_exchange.py index 6766095b..b4c94df0 100644 --- a/tests/gossip-unittests/test_client_peer_exchange.py +++ b/tests/gossip-unittests/test_client_peer_exchange.py @@ -71,7 +71,7 @@ class OnionrGossipClientGetNewPeers(unittest.TestCase): def test_get_new_peers_no_peers(self): gossip_peer_set.clear() - self.assertRaises(ValueError, get_new_peers) + get_new_peers() self.assertFalse(len(gossip_peer_set))