Catch JSON exceptions in PirateChainWalletController.

This could prevent additional wallets from being initialized if connection was lost while syncing an existing one.
This commit is contained in:
CalDescent 2022-10-05 15:29:29 +01:00
parent 1233ba6703
commit 10b0f0a054

View File

@ -4,6 +4,7 @@ import com.rust.litewalletjni.LiteWalletJni;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONException;
import org.json.JSONObject;
import org.qortal.arbitrary.ArbitraryDataFile;
import org.qortal.arbitrary.ArbitraryDataReader;
@ -99,6 +100,8 @@ public class PirateChainWalletController extends Thread {
LOGGER.debug("Syncing Pirate Chain wallet...");
String response = LiteWalletJni.execute("sync", "");
LOGGER.debug("sync response: {}", response);
try {
JSONObject json = new JSONObject(response);
if (json.has("result")) {
String result = json.getString("result");
@ -108,6 +111,9 @@ public class PirateChainWalletController extends Thread {
this.currentWallet.setReady(true);
}
}
} catch (JSONException e) {
LOGGER.info("Unable to interpret JSON", e);
}
// Rate limit sync attempts
Thread.sleep(30000);