do not backup trade wallet if arbitrator for space saving

This commit is contained in:
woodser 2024-01-25 06:34:20 -05:00
parent 8776fecef0
commit 221a63077c
3 changed files with 6 additions and 5 deletions

View File

@ -39,6 +39,7 @@ import java.util.List;
@Slf4j
public class FileUtil {
public static void rollingBackup(File dir, String fileName, int numMaxBackupFiles) {
if (numMaxBackupFiles <= 0) return;
if (dir.exists()) {
File backupDir = new File(Paths.get(dir.getAbsolutePath(), "backup").toString());
if (!backupDir.exists())

View File

@ -875,7 +875,7 @@ public abstract class Trade implements Tradable, Model {
public void saveWallet() {
synchronized (walletLock) {
if (wallet == null) throw new RuntimeException("Trade wallet is not open for trade " + getId());
xmrWalletService.saveWallet(wallet, true);
xmrWalletService.saveWallet(wallet, !isArbitrator()); // skip backup if arbitrator
}
}

View File

@ -107,7 +107,7 @@ public class XmrWalletService {
private static final String MONERO_WALLET_NAME = "haveno_XMR";
private static final String KEYS_FILE_POSTFIX = ".keys";
private static final String ADDRESS_FILE_POSTFIX = ".address.txt";
private static final int NUM_MAX_BACKUP_WALLETS = 1;
private static final int NUM_MAX_WALLET_BACKUPS = 1;
private static final int MONERO_LOG_LEVEL = 0;
private static final int MAX_SYNC_ATTEMPTS = 3;
private static final boolean PRINT_STACK_TRACE = false;
@ -361,9 +361,9 @@ public class XmrWalletService {
}
public void backupWallet(String walletName) {
FileUtil.rollingBackup(walletDir, walletName, NUM_MAX_BACKUP_WALLETS);
FileUtil.rollingBackup(walletDir, walletName + KEYS_FILE_POSTFIX, NUM_MAX_BACKUP_WALLETS);
FileUtil.rollingBackup(walletDir, walletName + ADDRESS_FILE_POSTFIX, NUM_MAX_BACKUP_WALLETS);
FileUtil.rollingBackup(walletDir, walletName, NUM_MAX_WALLET_BACKUPS);
FileUtil.rollingBackup(walletDir, walletName + KEYS_FILE_POSTFIX, NUM_MAX_WALLET_BACKUPS);
FileUtil.rollingBackup(walletDir, walletName + ADDRESS_FILE_POSTFIX, NUM_MAX_WALLET_BACKUPS);
}
public void deleteWalletBackups(String walletName) {