mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
Dump delayed txs of closed trades
This commit is contained in:
parent
8f92a6222e
commit
a551eef7d4
2 changed files with 10 additions and 4 deletions
|
@ -49,13 +49,14 @@ public class DumpDelayedPayoutTx {
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package bisq.core.trade.closed;
|
|||
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<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
|
||||
|
@ -70,6 +73,8 @@ public class ClosedTradableManager implements PersistedDataHost {
|
|||
trade.setTransientFields(tradableListStorage, btcWalletService);
|
||||
}
|
||||
});
|
||||
|
||||
dumpDelayedPayoutTx.maybeDumpDelayedPayoutTxs(closedTradables, "delayed_payout_txs_closed");
|
||||
}
|
||||
|
||||
public void add(Tradable tradable) {
|
||||
|
|
Loading…
Add table
Reference in a new issue