Tweaked some gossip timeout values and fixed tor not storing full address in config
This commit is contained in:
parent
3a7e378d8b
commit
9864fa5040
@ -8,8 +8,6 @@ from .deleteblock import delete_block
|
||||
from .getblocks import get_blocks_after_timestamp
|
||||
|
||||
|
||||
|
||||
|
||||
def clean_block_database():
|
||||
"""Delete expired blocks from block db"""
|
||||
remove_set: Set[bytes] = set()
|
||||
@ -21,5 +19,6 @@ def clean_block_database():
|
||||
except ValueError: # block expired
|
||||
remove_set.add(block)
|
||||
|
||||
logger.info(f"Cleaning {len(remove_set)} blocks", terminal=True)
|
||||
[i for i in map(delete_block, remove_set)]
|
||||
if len(remove_set):
|
||||
logger.info(f"Cleaning {len(remove_set)} blocks", terminal=True)
|
||||
[i for i in map(delete_block, remove_set)]
|
||||
|
@ -89,8 +89,10 @@ def start_gossip_client():
|
||||
"""
|
||||
bl: Block
|
||||
|
||||
|
||||
Thread(target=do_announce, daemon=True, name='do_announce').start()
|
||||
# Start a thread to announce our transport addresses to peers
|
||||
add_onionr_thread(
|
||||
do_announce,
|
||||
300, 'do_announce', initial_sleep=5)
|
||||
|
||||
# Start a thread that runs every 1200 secs to
|
||||
# Ask peers for a subset for their peer set
|
||||
|
@ -17,13 +17,14 @@ def do_announce():
|
||||
per_transport = 4
|
||||
peer_types = {}
|
||||
count_for_peer = 0
|
||||
|
||||
def _announce(announce_peer: 'Peer', our_transport_address: str):
|
||||
assert our_transport_address
|
||||
try:
|
||||
our_transport_address = our_transport_address.encode('utf-8') + b"\n"
|
||||
except AttributeError:
|
||||
our_transport_address = our_transport_address + b'\n'
|
||||
sock = announce_peer.get_socket(12)
|
||||
sock = announce_peer.get_socket(40)
|
||||
sock.sendall(command_to_byte(GossipCommands.ANNOUNCE))
|
||||
sock.sendall(our_transport_address)
|
||||
if int.from_bytes(sock.recv(1), 'big') != 1:
|
||||
@ -34,7 +35,6 @@ def do_announce():
|
||||
while not len(gossip_peer_set):
|
||||
sleep(1)
|
||||
|
||||
|
||||
for peer in gossip_peer_set:
|
||||
try:
|
||||
count_for_peer = peer_types[peer.__class__]
|
||||
|
@ -45,7 +45,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
MAX_STREAMS = 6
|
||||
CONNECT_TIMEOUT = 12
|
||||
CONNECT_TIMEOUT = 45
|
||||
MAX_TRIED_PEERS = 10_000
|
||||
|
||||
|
||||
@ -119,8 +119,8 @@ def stream_from_peers():
|
||||
# Tell them to keep streaming
|
||||
sock.sendall(int(1).to_bytes(1, 'big'))
|
||||
except (BrokenPipeError, TimeoutError) as e:
|
||||
logger.info(f"{e} when streaming peers", terminal=True)
|
||||
logger.debug(traceback.format_exc())
|
||||
logger.debug(f"{e} when streaming peers", terminal=True)
|
||||
#logger.debug(traceback.format_exc())
|
||||
except Exception:
|
||||
logger.warn(traceback.format_exc(), terminal=True)
|
||||
finally:
|
||||
|
@ -78,7 +78,7 @@ def gossip_server():
|
||||
threaded=True)
|
||||
writer.write(int(1).to_bytes(1, 'big'))
|
||||
await writer.drain()
|
||||
await asyncio.wait_for(_read_announce(), 10)
|
||||
await asyncio.wait_for(_read_announce(), 30)
|
||||
case GossipCommands.PEER_EXCHANGE:
|
||||
|
||||
for peer in gossip_peer_set:
|
||||
|
@ -87,7 +87,9 @@ def on_gossip_start(api, data: Set[Peer] = None):
|
||||
key_content='BEST', key_type='NEW', detached=True)
|
||||
config.set('tor.key', add_onion_resp.private_key, savefile=True)
|
||||
new_address = 'Generated '
|
||||
config.set('tor.transport_address', add_onion_resp.service_id,
|
||||
onion = add_onion_resp.service_id
|
||||
onion = onion.removesuffix('.onion') + '.onion'
|
||||
config.set('tor.transport_address', onion,
|
||||
savefile=True)
|
||||
else:
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user