From bb32526210dc2fe6f800e79e8ceaddff15ceafdd Mon Sep 17 00:00:00 2001 From: sqrrm Date: Sun, 15 Mar 2020 16:09:37 +0100 Subject: [PATCH] Dump delayed txs of closed trades --- .../main/java/bisq/core/trade/DumpDelayedPayoutTx.java | 5 +++-- .../bisq/core/trade/closed/ClosedTradableManager.java | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/bisq/core/trade/DumpDelayedPayoutTx.java b/core/src/main/java/bisq/core/trade/DumpDelayedPayoutTx.java index 0f5669f751e..76a0e86de9e 100644 --- a/core/src/main/java/bisq/core/trade/DumpDelayedPayoutTx.java +++ b/core/src/main/java/bisq/core/trade/DumpDelayedPayoutTx.java @@ -49,13 +49,14 @@ static class DelayedPayoutHash { } } - public void maybeDumpDelayedPayoutTxs(TradableList tradableList, String fileName) { + public void maybeDumpDelayedPayoutTxs(TradableList tradableList, String fileName) { if (!dumpDelayedPayoutTxs) return; var delayedPayoutHashes = tradableList.stream() + .filter(tradable -> tradable instanceof Trade) .map(trade -> new DelayedPayoutHash(trade.getId(), - Utilities.bytesAsHexString(trade.getDelayedPayoutTxBytes()))) + Utilities.bytesAsHexString(((Trade) trade).getDelayedPayoutTxBytes()))) .collect(Collectors.toList()); jsonFileManager.writeToDisc(Utilities.objectToJson(delayedPayoutHashes), fileName); } diff --git a/core/src/main/java/bisq/core/trade/closed/ClosedTradableManager.java b/core/src/main/java/bisq/core/trade/closed/ClosedTradableManager.java index 2184600b058..7922511c00f 100644 --- a/core/src/main/java/bisq/core/trade/closed/ClosedTradableManager.java +++ b/core/src/main/java/bisq/core/trade/closed/ClosedTradableManager.java @@ -20,6 +20,7 @@ import bisq.core.btc.wallet.BtcWalletService; import bisq.core.offer.Offer; import bisq.core.provider.price.PriceFeedService; +import bisq.core.trade.DumpDelayedPayoutTx; import bisq.core.trade.Tradable; import bisq.core.trade.TradableList; import bisq.core.trade.Trade; @@ -45,19 +46,21 @@ public class ClosedTradableManager implements PersistedDataHost { private final KeyRing keyRing; private final PriceFeedService priceFeedService; private final BtcWalletService btcWalletService; + private final DumpDelayedPayoutTx dumpDelayedPayoutTx; @Inject public ClosedTradableManager(KeyRing keyRing, PriceFeedService priceFeedService, BtcWalletService btcWalletService, - Storage> storage) { + Storage> storage, + DumpDelayedPayoutTx dumpDelayedPayoutTx) { this.keyRing = keyRing; this.priceFeedService = priceFeedService; this.btcWalletService = btcWalletService; tradableListStorage = storage; + this.dumpDelayedPayoutTx = dumpDelayedPayoutTx; // The ClosedTrades object can become a few MB so we don't keep so many backups tradableListStorage.setNumMaxBackupFiles(3); - } @Override @@ -70,6 +73,8 @@ public void readPersisted() { trade.setTransientFields(tradableListStorage, btcWalletService); } }); + + dumpDelayedPayoutTx.maybeDumpDelayedPayoutTxs(closedTradables, "delayed_payout_txs_closed"); } public void add(Tradable tradable) {