Browse Source

Small gossip fixes

newtransport
Kevin F 2 weeks ago
parent
commit
6b6d357a13
  1. 1
      src/filepaths/__init__.py
  2. 2
      src/gossip/client/storeblocks.py
  3. 2
      src/utils/createdirs.py
  4. 7
      static-data/default-plugins/tor/announce.py
  5. 2
      tests/gossip-unittests/test_client_peer_exchange.py

1
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'

2
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

2
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:

7
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'

2
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))

Loading…
Cancel
Save