mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Also dump failed trades delayed payout txs
This commit is contained in:
parent
40fb1ab49f
commit
df54c121f6
@ -17,24 +17,42 @@
|
||||
|
||||
package bisq.core.trade;
|
||||
|
||||
import bisq.common.config.Config;
|
||||
import bisq.common.storage.JsonFileManager;
|
||||
import bisq.common.util.Utilities;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class DumpDelayedPayoutTx {
|
||||
public class DumpDelayedPayoutTx {
|
||||
private final boolean dumpDelayedPayoutTxs;
|
||||
private final JsonFileManager jsonFileManager;
|
||||
|
||||
@Inject
|
||||
DumpDelayedPayoutTx(@Named(Config.STORAGE_DIR) File storageDir,
|
||||
@Named(Config.DUMP_DELAYED_PAYOUT_TXS) boolean dumpDelayedPayoutTxs) {
|
||||
this.dumpDelayedPayoutTxs = dumpDelayedPayoutTxs;
|
||||
jsonFileManager = new JsonFileManager(storageDir);
|
||||
}
|
||||
|
||||
static class DelayedPayoutHash {
|
||||
String tradeId;
|
||||
String delayedPayoutTx;
|
||||
|
||||
DelayedPayoutHash(String tradeId, String delayedPayoutTx) {
|
||||
this.tradeId = tradeId;
|
||||
this.delayedPayoutTx = delayedPayoutTx;
|
||||
}
|
||||
}
|
||||
|
||||
static void dumpDelayedPayoutTxs(TradableList<Trade> tradableList, JsonFileManager jsonFileManager,
|
||||
String fileName) {
|
||||
public void maybeDumpDelayedPayoutTxs(TradableList<Trade> tradableList, String fileName) {
|
||||
if (!dumpDelayedPayoutTxs)
|
||||
return;
|
||||
|
||||
var delayedPayoutHashes = tradableList.stream()
|
||||
.map(trade -> new DelayedPayoutHash(trade.getId(),
|
||||
Utilities.bytesAsHexString(trade.getDelayedPayoutTxBytes())))
|
||||
|
@ -57,14 +57,12 @@ import bisq.network.p2p.P2PService;
|
||||
import bisq.network.p2p.SendMailboxMessageListener;
|
||||
|
||||
import bisq.common.ClockWatcher;
|
||||
import bisq.common.config.Config;
|
||||
import bisq.common.crypto.KeyRing;
|
||||
import bisq.common.handlers.ErrorMessageHandler;
|
||||
import bisq.common.handlers.FaultHandler;
|
||||
import bisq.common.handlers.ResultHandler;
|
||||
import bisq.common.proto.network.NetworkEnvelope;
|
||||
import bisq.common.proto.persistable.PersistedDataHost;
|
||||
import bisq.common.storage.JsonFileManager;
|
||||
import bisq.common.storage.Storage;
|
||||
|
||||
import org.bitcoinj.core.AddressFormatException;
|
||||
@ -74,7 +72,6 @@ import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.core.TransactionConfidence;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
|
||||
@ -89,8 +86,6 @@ import javafx.collections.ObservableList;
|
||||
|
||||
import org.spongycastle.crypto.params.KeyParameter;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -146,8 +141,7 @@ public class TradeManager implements PersistedDataHost {
|
||||
private final LongProperty numPendingTrades = new SimpleLongProperty();
|
||||
@Getter
|
||||
private final ObservableList<Trade> tradesWithoutDepositTx = FXCollections.observableArrayList();
|
||||
private final boolean dumpDelayedPayoutTxs;
|
||||
private final JsonFileManager jsonFileManager;
|
||||
private final DumpDelayedPayoutTx dumpDelayedPayoutTx;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -175,8 +169,7 @@ public class TradeManager implements PersistedDataHost {
|
||||
DaoFacade daoFacade,
|
||||
ClockWatcher clockWatcher,
|
||||
Storage<TradableList<Trade>> storage,
|
||||
@Named(Config.STORAGE_DIR) File storageDir,
|
||||
@Named(Config.DUMP_DELAYED_PAYOUT_TXS) boolean dumpDelayedPayoutTxs) {
|
||||
DumpDelayedPayoutTx dumpDelayedPayoutTx) {
|
||||
this.user = user;
|
||||
this.keyRing = keyRing;
|
||||
this.btcWalletService = btcWalletService;
|
||||
@ -196,7 +189,7 @@ public class TradeManager implements PersistedDataHost {
|
||||
this.refundAgentManager = refundAgentManager;
|
||||
this.daoFacade = daoFacade;
|
||||
this.clockWatcher = clockWatcher;
|
||||
this.dumpDelayedPayoutTxs = dumpDelayedPayoutTxs;
|
||||
this.dumpDelayedPayoutTx = dumpDelayedPayoutTx;
|
||||
|
||||
tradableListStorage = storage;
|
||||
|
||||
@ -232,9 +225,6 @@ public class TradeManager implements PersistedDataHost {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
jsonFileManager = new JsonFileManager(storageDir);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -247,9 +237,7 @@ public class TradeManager implements PersistedDataHost {
|
||||
offer.setPriceFeedService(priceFeedService);
|
||||
});
|
||||
|
||||
if (dumpDelayedPayoutTxs){
|
||||
DumpDelayedPayoutTx.dumpDelayedPayoutTxs(tradableList, jsonFileManager, "delayed_payout_txs");
|
||||
}
|
||||
dumpDelayedPayoutTx.maybeDumpDelayedPayoutTxs(tradableList, "delayed_payout_txs_pending");
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@ package bisq.core.trade.failed;
|
||||
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.TradableList;
|
||||
import bisq.core.trade.Trade;
|
||||
|
||||
@ -44,17 +45,19 @@ public class FailedTradesManager implements PersistedDataHost {
|
||||
private final PriceFeedService priceFeedService;
|
||||
private final BtcWalletService btcWalletService;
|
||||
private final Storage<TradableList<Trade>> tradableListStorage;
|
||||
private final DumpDelayedPayoutTx dumpDelayedPayoutTx;
|
||||
|
||||
@Inject
|
||||
public FailedTradesManager(KeyRing keyRing,
|
||||
PriceFeedService priceFeedService,
|
||||
BtcWalletService btcWalletService,
|
||||
Storage<TradableList<Trade>> storage) {
|
||||
Storage<TradableList<Trade>> storage,
|
||||
DumpDelayedPayoutTx dumpDelayedPayoutTx) {
|
||||
this.keyRing = keyRing;
|
||||
this.priceFeedService = priceFeedService;
|
||||
this.btcWalletService = btcWalletService;
|
||||
tradableListStorage = storage;
|
||||
|
||||
this.dumpDelayedPayoutTx = dumpDelayedPayoutTx;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -67,6 +70,8 @@ public class FailedTradesManager implements PersistedDataHost {
|
||||
|
||||
trade.setTransientFields(tradableListStorage, btcWalletService);
|
||||
});
|
||||
|
||||
dumpDelayedPayoutTx.maybeDumpDelayedPayoutTxs(failedTrades, "delayed_payout_txs_failed");
|
||||
}
|
||||
|
||||
public void add(Trade trade) {
|
||||
|
Loading…
Reference in New Issue
Block a user