Skip to content

Commit

Permalink
Merge pull request #4066 from sqrrm/dump-closed-delayedtx
Browse files Browse the repository at this point in the history
Dump delayed txs of closed trades
  • Loading branch information
ripcurlx committed Mar 16, 2020
2 parents d30c5a8 + bb32526 commit a7e6b99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions core/src/main/java/bisq/core/trade/DumpDelayedPayoutTx.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ static class DelayedPayoutHash {
}
}

public void maybeDumpDelayedPayoutTxs(TradableList<Trade> tradableList, String fileName) {
public <T extends Tradable> void maybeDumpDelayedPayoutTxs(TradableList<T> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<TradableList<Tradable>> storage) {
Storage<TradableList<Tradable>> 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
Expand All @@ -70,6 +73,8 @@ public void readPersisted() {
trade.setTransientFields(tradableListStorage, btcWalletService);
}
});

dumpDelayedPayoutTx.maybeDumpDelayedPayoutTxs(closedTradables, "delayed_payout_txs_closed");
}

public void add(Tradable tradable) {
Expand Down

0 comments on commit a7e6b99

Please sign in to comment.