Skip to content

Commit

Permalink
Updated staker to reload unloaded wallet while running
Browse files Browse the repository at this point in the history
  • Loading branch information
mxaddict committed Aug 10, 2024
1 parent a9347aa commit cc48ad3
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/navio-staker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}

Expand Down Expand Up @@ -785,7 +785,15 @@ void Loop()
LogPrintf("%s: [%s] Starting staking...\n", __func__, walletName);

while (true) {
auto staked_commitments = GetStakedCommitments(rh);
std::vector<StakedCommitment> 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;
Expand Down Expand Up @@ -859,11 +867,9 @@ MAIN_FUNCTION
return EXIT_FAILURE;
}

int ret = EXIT_FAILURE;

Setup();
if (!TestSetup())
return ret;
return EXIT_FAILURE;

Loop();

Expand Down

0 comments on commit cc48ad3

Please sign in to comment.