Fix logging in AbstractBot's maybeShutdownAfterSuccessfulSwap()

This commit is contained in:
ghubstan 2022-07-01 12:39:17 -03:00
parent 1f45116849
commit 5384d3ac59
No known key found for this signature in database
GPG Key ID: E35592D6800A861E

View File

@ -795,35 +795,30 @@ public abstract class AbstractBot {
} }
/** /**
* Print the day's completed trades since midnight today, then: * Print the day's completed trades since midnight today, and number of offers taken during the bot session, then,
* <p> * <p>
* If numOffersTaken >= maxTakeOffers, and trade completion is being simulated on regtest, shut down the bot. * If numOffersTaken >= maxTakeOffers, shut down the bot.
* <p> * <p>
* If numOffersTaken >= maxTakeOffers, and mainnet trade completion must be delegated to the UI, shut down the * If numOffersTaken < maxTakeOffers, log the number of offers taken so far during the bot run.
* API daemon and the bot.
* <p>
* If numOffersTaken < maxTakeOffers, just log the number of offers taken so far during the bot run.
* (Don't shut down anything.)
* *
* @param numOffersTaken the number of offers taken during bot run * @param numOffersTaken the number of offers taken during bot run
* @param maxTakeOffers the max number of offers that can be taken during bot run * @param maxTakeOffers the max number of offers that can be taken during bot run
*/ */
protected void maybeShutdownAfterSuccessfulSwap(int numOffersTaken, int maxTakeOffers) { protected void maybeShutdownAfterSuccessfulSwap(int numOffersTaken, int maxTakeOffers) {
printTradesSummaryForToday(CLOSED); printTradesSummaryForTodayIfWalletIsUnlocked();
if (!isDryRun) { log.info("You {} have taken {} swap offer(s) during this bot's {}",
try { isDryRun ? "would" : "",
lockWallet(); numOffersTaken,
} catch (NonFatalException ex) { isDryRun ? "dryrun:" : "session.");
log.warn(ex.getMessage()); if (isDryRun) {
} printDryRunProgress();
} }
if (numOffersTaken >= maxTakeOffers) { if (numOffersTaken >= maxTakeOffers) {
isShutdown = true; isShutdown = true;
log.info("Shutting down API bot after executing {} BSQ swaps.", numOffersTaken); log.info("Shutting down API bot after executing {} BSQ swaps.", numOffersTaken);
exit(0); exit(0);
} else {
log.info("You have completed {} BSQ swap(s) during this bot session.", numOffersTaken);
} }
} }