Sync DB schema to table definitions.

This commit is contained in:
tecnovert
2025-05-25 23:27:05 +02:00
parent f3adc17bb8
commit 3faf947588
5 changed files with 240 additions and 343 deletions

View File

@@ -31,8 +31,6 @@ if not len(initial_logger.handlers):
logger = initial_logger
swap_client = None
with_coins = set()
without_coins = set()
class Daemon:
@@ -285,7 +283,11 @@ def getCoreBinArgs(coin_id: int, coin_settings, prepare=False, use_tor_proxy=Fal
def runClient(
data_dir: str, chain: str, start_only_coins: bool, log_prefix: str = "BasicSwap"
data_dir: str,
chain: str,
start_only_coins: bool,
log_prefix: str = "BasicSwap",
extra_opts=dict(),
) -> int:
global swap_client, logger
daemons = []
@@ -311,13 +313,6 @@ def runClient(
with open(settings_path) as fs:
settings = json.load(fs)
extra_opts = dict()
if len(with_coins) > 0:
with_coins.add("particl")
extra_opts["with_coins"] = with_coins
if len(without_coins) > 0:
extra_opts["without_coins"] = without_coins
swap_client = BasicSwap(
data_dir, settings, chain, log_name=log_prefix, extra_opts=extra_opts
)
@@ -334,12 +329,16 @@ def runClient(
# Settings may have been modified
settings = swap_client.settings
try:
# Try start daemons
for c, v in settings["chainclients"].items():
if len(start_only_coins) > 0 and c not in start_only_coins:
continue
if (len(with_coins) > 0 and c not in with_coins) or c in without_coins:
if (
len(swap_client.with_coins_override) > 0
and c not in swap_client.with_coins_override
) or c in swap_client.without_coins_override:
if v.get("manage_daemon", False) or v.get(
"manage_wallet_daemon", False
):
@@ -623,6 +622,9 @@ def printHelp():
"--startonlycoin Only start the provides coin daemon/s, use this if a chain requires extra processing."
)
print("--logprefix Specify log prefix.")
print(
"--forcedbupgrade Recheck database against schema regardless of version."
)
def main():
@@ -630,6 +632,9 @@ def main():
chain = "mainnet"
start_only_coins = set()
log_prefix: str = "BasicSwap"
options = dict()
with_coins = set()
without_coins = set()
for v in sys.argv[1:]:
if len(v) < 2 or v[0] != "-":
@@ -665,6 +670,9 @@ def main():
ensure_coin_valid(coin)
without_coins.add(coin)
continue
if name == "forcedbupgrade":
options["force_db_upgrade"] = True
continue
if len(s) == 2:
if name == "datadir":
data_dir = os.path.expanduser(s[1])
@@ -693,8 +701,14 @@ def main():
if not os.path.exists(data_dir):
os.makedirs(data_dir)
if len(with_coins) > 0:
with_coins.add("particl")
options["with_coins"] = with_coins
if len(without_coins) > 0:
options["without_coins"] = without_coins
logger.info(os.path.basename(sys.argv[0]) + ", version: " + __version__ + "\n\n")
fail_code = runClient(data_dir, chain, start_only_coins, log_prefix)
fail_code = runClient(data_dir, chain, start_only_coins, log_prefix, options)
print("Done.")
return fail_code