mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 10:28:10 +01:00
network: Use simplex direct chats by default.
This commit is contained in:
@@ -445,7 +445,7 @@ class BasicSwap(BaseApp, UIApp):
|
|||||||
)
|
)
|
||||||
self._max_check_loop_blocks = self.settings.get("max_check_loop_blocks", 100000)
|
self._max_check_loop_blocks = self.settings.get("max_check_loop_blocks", 100000)
|
||||||
self._bid_expired_leeway = 5
|
self._bid_expired_leeway = 5
|
||||||
self._use_direct_message_routes = False
|
self._use_direct_message_routes = True
|
||||||
|
|
||||||
self.swaps_in_progress = dict()
|
self.swaps_in_progress = dict()
|
||||||
|
|
||||||
@@ -3981,6 +3981,11 @@ class BasicSwap(BaseApp, UIApp):
|
|||||||
if self._use_direct_message_routes is False:
|
if self._use_direct_message_routes is False:
|
||||||
return None, False
|
return None, False
|
||||||
|
|
||||||
|
try:
|
||||||
|
net_i = self.getActiveNetworkInterface(2)
|
||||||
|
except Exception as e: # noqa: F841
|
||||||
|
return None, False
|
||||||
|
|
||||||
# Look for active route
|
# Look for active route
|
||||||
message_route = self.getMessageRoute(1, addr_from, addr_to, cursor=cursor)
|
message_route = self.getMessageRoute(1, addr_from, addr_to, cursor=cursor)
|
||||||
self.log.debug(f"Using active message route: {message_route}")
|
self.log.debug(f"Using active message route: {message_route}")
|
||||||
@@ -3993,7 +3998,6 @@ class BasicSwap(BaseApp, UIApp):
|
|||||||
if message_route:
|
if message_route:
|
||||||
return message_route.record_id, False
|
return message_route.record_id, False
|
||||||
|
|
||||||
net_i = self.getActiveNetworkInterface(2)
|
|
||||||
cmd_id = net_i.send_command("/connect")
|
cmd_id = net_i.send_command("/connect")
|
||||||
response = net_i.wait_for_command_response(cmd_id)
|
response = net_i.wait_for_command_response(cmd_id)
|
||||||
connReqInvitation = response["resp"]["connReqInvitation"]
|
connReqInvitation = response["resp"]["connReqInvitation"]
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ def startDaemon(node_dir, bin_dir, daemon_bin, opts=[], extra_config={}):
|
|||||||
cwd=datadir_path,
|
cwd=datadir_path,
|
||||||
),
|
),
|
||||||
opened_files,
|
opened_files,
|
||||||
|
os.path.basename(daemon_bin),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -152,6 +153,7 @@ def startXmrDaemon(node_dir, bin_dir, daemon_bin, opts=[]):
|
|||||||
cwd=datadir_path,
|
cwd=datadir_path,
|
||||||
),
|
),
|
||||||
[file_stdout, file_stderr],
|
[file_stdout, file_stderr],
|
||||||
|
os.path.basename(daemon_bin),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -215,6 +217,7 @@ def startXmrWalletDaemon(node_dir, bin_dir, wallet_bin, opts=[]):
|
|||||||
cwd=data_dir,
|
cwd=data_dir,
|
||||||
),
|
),
|
||||||
[wallet_stdout, wallet_stderr],
|
[wallet_stdout, wallet_stderr],
|
||||||
|
os.path.basename(wallet_bin),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -340,7 +343,7 @@ def runClient(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
pid = daemons[-1].handle.pid
|
pid = daemons[-1].handle.pid
|
||||||
swap_client.log.info(f"Started Simpelx client {pid}")
|
swap_client.log.info(f"Started Simplex client {pid}")
|
||||||
|
|
||||||
for c, v in settings["chainclients"].items():
|
for c, v in settings["chainclients"].items():
|
||||||
if len(start_only_coins) > 0 and c not in start_only_coins:
|
if len(start_only_coins) > 0 and c not in start_only_coins:
|
||||||
@@ -569,13 +572,13 @@ def runClient(
|
|||||||
|
|
||||||
closed_pids = []
|
closed_pids = []
|
||||||
for d in daemons:
|
for d in daemons:
|
||||||
swap_client.log.info(f"Interrupting {d.handle.pid}")
|
swap_client.log.info(f"Interrupting {d.name} {d.handle.pid}")
|
||||||
try:
|
try:
|
||||||
d.handle.send_signal(
|
d.handle.send_signal(
|
||||||
signal.CTRL_C_EVENT if os.name == "nt" else signal.SIGINT
|
signal.CTRL_C_EVENT if os.name == "nt" else signal.SIGINT
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
swap_client.log.info(f"Interrupting {d.handle.pid}, error {e}")
|
swap_client.log.info(f"Interrupting {d.name} {d.handle.pid}, error {e}")
|
||||||
for d in daemons:
|
for d in daemons:
|
||||||
try:
|
try:
|
||||||
d.handle.wait(timeout=120)
|
d.handle.wait(timeout=120)
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ def startSimplexClient(
|
|||||||
db_path = os.path.join(data_path, "simplex_client_data")
|
db_path = os.path.join(data_path, "simplex_client_data")
|
||||||
args = [bin_path, "-d", db_path, "-s", server_address, "-p", str(websocket_port)]
|
args = [bin_path, "-d", db_path, "-s", server_address, "-p", str(websocket_port)]
|
||||||
|
|
||||||
if not os.path.exists(db_path):
|
if not os.path.exists(db_path + "_chat.db"):
|
||||||
# Need to set initial profile through CLI
|
# Need to set initial profile through CLI
|
||||||
# TODO: Must be a better way?
|
# TODO: Must be a better way?
|
||||||
init_args = args + ["-e", "/help"] # Run command ro exit client
|
init_args = args + ["-e", "/help"] # Run command ro exit client
|
||||||
@@ -103,4 +103,5 @@ def startSimplexClient(
|
|||||||
cwd=data_path,
|
cwd=data_path,
|
||||||
),
|
),
|
||||||
opened_files,
|
opened_files,
|
||||||
|
"simplex-chat",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,8 +6,9 @@
|
|||||||
|
|
||||||
|
|
||||||
class Daemon:
|
class Daemon:
|
||||||
__slots__ = ("handle", "files")
|
__slots__ = ("handle", "files", "name")
|
||||||
|
|
||||||
def __init__(self, handle, files):
|
def __init__(self, handle, files, name):
|
||||||
self.handle = handle
|
self.handle = handle
|
||||||
self.files = files
|
self.files = files
|
||||||
|
self.name = name
|
||||||
|
|||||||
@@ -446,7 +446,6 @@ class Test(BaseTest):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def addCoinSettings(cls, settings, datadir, node_id):
|
def addCoinSettings(cls, settings, datadir, node_id):
|
||||||
|
|
||||||
settings["networks"] = [
|
settings["networks"] = [
|
||||||
{
|
{
|
||||||
"type": "simplex",
|
"type": "simplex",
|
||||||
@@ -463,7 +462,7 @@ class Test(BaseTest):
|
|||||||
swap_clients = self.swap_clients
|
swap_clients = self.swap_clients
|
||||||
|
|
||||||
for sc in swap_clients:
|
for sc in swap_clients:
|
||||||
sc._use_direct_messages = False
|
sc._use_direct_message_routes = False
|
||||||
|
|
||||||
assert len(swap_clients[0].active_networks) == 1
|
assert len(swap_clients[0].active_networks) == 1
|
||||||
assert swap_clients[0].active_networks[0]["type"] == "simplex"
|
assert swap_clients[0].active_networks[0]["type"] == "simplex"
|
||||||
@@ -521,7 +520,7 @@ class Test(BaseTest):
|
|||||||
swap_clients = self.swap_clients
|
swap_clients = self.swap_clients
|
||||||
|
|
||||||
for sc in swap_clients:
|
for sc in swap_clients:
|
||||||
sc._use_direct_messages = False
|
sc._use_direct_message_routes = False
|
||||||
|
|
||||||
assert len(swap_clients[0].active_networks) == 1
|
assert len(swap_clients[0].active_networks) == 1
|
||||||
assert swap_clients[0].active_networks[0]["type"] == "simplex"
|
assert swap_clients[0].active_networks[0]["type"] == "simplex"
|
||||||
|
|||||||
Reference in New Issue
Block a user