From cc48ad356e44535758c3f955349bb01f1dd36631 Mon Sep 17 00:00:00 2001 From: mxaddict Date: Wed, 31 Jul 2024 23:04:03 +0800 Subject: [PATCH] Updated staker to reload unloaded wallet while running --- src/navio-staker.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/navio-staker.cpp b/src/navio-staker.cpp index 7055e5a96d7514..15704a54a14ed8 100644 --- a/src/navio-staker.cpp +++ b/src/navio-staker.cpp @@ -627,7 +627,7 @@ bool TestSetup() } } - LogPrintf("%s: [%s] Rewards address: %s\n", __func__, walletName, coinbase_dest); + LogPrintf("%s: [%s] Rewards address: (%s)\n", __func__, walletName, coinbase_dest); return true; } else { @@ -639,11 +639,11 @@ bool TestSetup() return false; } } else { - LogPrintf("%s: [%s] Could not connect to RPC node: %s\n", __func__, walletName, error.getValStr()); + LogPrintf("%s: [%s] Could not connect to RPC node: (%s)\n", __func__, walletName, error.getValStr()); return false; } } catch (const std::exception& e) { - LogPrintf("%s: [%s] error: %s\n", __func__, walletName, e.what()); + LogPrintf("%s: [%s] error: (%s)\n", __func__, walletName, e.what()); return false; } @@ -785,7 +785,15 @@ void Loop() LogPrintf("%s: [%s] Starting staking...\n", __func__, walletName); while (true) { - auto staked_commitments = GetStakedCommitments(rh); + std::vector staked_commitments; + try { + staked_commitments = GetStakedCommitments(rh); + } catch (const std::exception& e) { + LogPrintf("%s: [%s] Could not load stake commitments, reloading wallet...\n", __func__, walletName); + ConnectAndCallRPC(rh.get(), "loadwallet", /* args=*/{walletName}); + staked_commitments = GetStakedCommitments(rh); + } + CBlock proposal; CAmount nTotalMoney = 0; bool found = false; @@ -859,11 +867,9 @@ MAIN_FUNCTION return EXIT_FAILURE; } - int ret = EXIT_FAILURE; - Setup(); if (!TestSetup()) - return ret; + return EXIT_FAILURE; Loop();