Merge pull request #335 from nahuhh/pr/wow_dedup

wow: cleanup some dups in prepare.py and basicswap.py
This commit is contained in:
Gerlof van Ek
2025-07-23 23:53:56 +02:00
committed by GitHub
2 changed files with 6 additions and 60 deletions

View File

@@ -259,32 +259,6 @@ def threadPollXMRChainState(swap_client, coin_type):
) # Random to stagger updates
def threadPollWOWChainState(swap_client, coin_type):
ci = swap_client.ci(coin_type)
cc = swap_client.coin_clients[coin_type]
while not swap_client.chainstate_delay_event.is_set():
try:
new_height: int = ci.getChainHeight()
if new_height != cc["chain_height"]:
swap_client.log.debug(
f"New {ci.ticker()} block at height: {new_height}"
)
with swap_client.mxDB:
cc["chain_height"] = new_height
checkAndNotifyBalanceChange(
swap_client, coin_type, ci, cc, new_height, "block"
)
except Exception as e:
swap_client.log.warning(
f"threadPollWOWChainState {ci.ticker()}, error: {e}"
)
swap_client.chainstate_delay_event.wait(
random.randrange(20, 30)
) # Random to stagger updates
def threadPollChainState(swap_client, coin_type):
ci = swap_client.ci(coin_type)
cc = swap_client.coin_clients[coin_type]
@@ -1150,7 +1124,7 @@ class BasicSwap(BaseApp, UIApp):
thread_func = {
Coins.XMR: threadPollXMRChainState,
Coins.WOW: threadPollWOWChainState,
Coins.WOW: threadPollXMRChainState,
}.get(
c, threadPollChainState
) # default case

View File

@@ -356,21 +356,6 @@ monero_wallet_rpc_proxy_config = [
# 'daemon-ssl-allow-any-cert=1', moved to startup flag
]
wownerod_proxy_config = [
f"proxy={TOR_PROXY_HOST}:{TOR_PROXY_PORT}",
"proxy-allow-dns-leaks=0",
"no-igd=1", # Disable UPnP port mapping
"hide-my-port=1", # Don't share the p2p port
"p2p-bind-ip=127.0.0.1", # Don't broadcast ip
"in-peers=0", # Changes "error" in log to "incoming connections disabled"
"out-peers=24",
f"tx-proxy=tor,{TOR_PROXY_HOST}:{TOR_PROXY_PORT},disable_noise,16", # Outgoing tx relay to onion
]
wownero_wallet_rpc_proxy_config = [
# 'daemon-ssl-allow-any-cert=1', moved to startup flag
]
default_socket = socket.socket
default_socket_timeout = socket.getdefaulttimeout()
default_socket_getaddrinfo = socket.getaddrinfo
@@ -1223,15 +1208,11 @@ def prepareDataDir(coin, settings, chain, particl_mnemonic, extra_opts={}):
if coin == "monero":
if XMR_RPC_USER != "":
fp.write(f"rpc-login={XMR_RPC_USER}:{XMR_RPC_PWD}\n")
if tor_control_password is not None:
for opt_line in monerod_proxy_config:
fp.write(opt_line + "\n")
if coin == "wownero":
if WOW_RPC_USER != "":
fp.write(f"rpc-login={WOW_RPC_USER}:{WOW_RPC_PWD}\n")
if tor_control_password is not None:
for opt_line in wownerod_proxy_config:
for opt_line in monerod_proxy_config:
fp.write(opt_line + "\n")
wallets_dir = core_settings.get("walletsdir", data_dir)
@@ -1567,27 +1548,18 @@ def modify_tor_config(
# Disable tor first
for line in fp_in:
skip_line: bool = False
if coin == "monero":
if coin in ("wownero", "monero"):
for opt_line in monerod_proxy_config:
setting: str = opt_line[0 : opt_line.find("=") + 1]
if line.startswith(setting):
skip_line = True
break
if coin == "wownero":
for opt_line in wownerod_proxy_config:
setting: str = opt_line[0 : opt_line.find("=") + 1]
if line.startswith(setting):
skip_line = True
break
if not skip_line:
fp.write(line)
if enable:
if coin == "monero":
if coin in ("wownero", "monero"):
for opt_line in monerod_proxy_config:
fp.write(opt_line + "\n")
if coin == "wownero":
for opt_line in wownerod_proxy_config:
fp.write(opt_line + "\n")
with open(wallet_conf_path, "w") as fp:
with open(wallet_conf_path + ".last") as fp_in: