Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump delayed txs of closed trades #4066

Merged
merged 1 commit into from
Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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