mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-09-20 08:05:33 +03:00
Remove useless connection close, and fix ssh ui bug
This commit is contained in:
parent
adc6b35fdb
commit
4353e6658e
@ -1,9 +1,6 @@
|
||||
network_id: testnet # testnet/mainnet
|
||||
# Send a ping to all peers after ping_interval seconds
|
||||
ping_interval: 300
|
||||
# Close the connection if no data is received for timeout_duration seconds.
|
||||
# Must be greater than ping_interval
|
||||
timeout_duration: 3000
|
||||
ping_interval: 120
|
||||
|
||||
harvester:
|
||||
# The harvester server (if run) will run on this host and port
|
||||
|
@ -3,7 +3,6 @@ import logging
|
||||
import random
|
||||
import os
|
||||
import concurrent
|
||||
import time
|
||||
from secrets import token_bytes
|
||||
from yaml import safe_load
|
||||
from typing import Any, AsyncGenerator, List, Optional, Tuple
|
||||
@ -174,20 +173,6 @@ class ChiaServer:
|
||||
def _initialize_ping_task(self):
|
||||
async def ping():
|
||||
while not self._pipeline_task.done():
|
||||
to_close: List[Connection] = []
|
||||
for connection in self.global_connections.get_connections():
|
||||
if connection.handshake_finished:
|
||||
if (
|
||||
time.time() - connection.get_last_message_time()
|
||||
> config["timeout_duration"]
|
||||
and connection.connection_type == NodeType.FULL_NODE
|
||||
and self._local_type == NodeType.FULL_NODE
|
||||
):
|
||||
# Only closes down full_node <-> full_node connections, which can be recovered
|
||||
to_close.append(connection)
|
||||
for connection in to_close:
|
||||
log.info(f"Removing connection {connection} due to timeout.")
|
||||
self.global_connections.close(connection)
|
||||
msg = Message("ping", Ping(bytes32(token_bytes(32))))
|
||||
self.push_message(
|
||||
OutboundMessage(NodeType.FARMER, msg, Delivery.BROADCAST)
|
||||
@ -202,7 +187,6 @@ class ChiaServer:
|
||||
OutboundMessage(NodeType.HARVESTER, msg, Delivery.BROADCAST)
|
||||
)
|
||||
await asyncio.sleep(config["ping_interval"])
|
||||
|
||||
return asyncio.create_task(ping())
|
||||
|
||||
def initialize_pipeline(self, aiter, api: Any, server_port: int) -> asyncio.Task:
|
||||
|
@ -84,6 +84,7 @@ async def start_ssh_server(
|
||||
except ConnectionError:
|
||||
log.info("Connection error in ssh UI, exiting.")
|
||||
ui.close()
|
||||
# raise
|
||||
|
||||
ssh_server = await asyncssh.create_server(
|
||||
lambda: PromptToolkitSSHServer(interact),
|
||||
@ -480,7 +481,7 @@ class FullNodeUI:
|
||||
|
||||
if self.app and not self.app.invalidated:
|
||||
self.app.invalidate()
|
||||
await asyncio.sleep(0.25)
|
||||
await asyncio.sleep(1)
|
||||
except concurrent.futures._base.CancelledError as e:
|
||||
log.warn(f"Cancelled error in UI: {type(e)}: {e}")
|
||||
except Exception as e:
|
||||
|
Loading…
Reference in New Issue
Block a user