mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
Move dump delaytx to separate class
This commit is contained in:
parent
a926f2b260
commit
40fb1ab49f
2 changed files with 49 additions and 23 deletions
45
core/src/main/java/bisq/core/trade/DumpDelayedPayoutTx.java
Normal file
45
core/src/main/java/bisq/core/trade/DumpDelayedPayoutTx.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.core.trade;
|
||||
|
||||
import bisq.common.storage.JsonFileManager;
|
||||
import bisq.common.util.Utilities;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class DumpDelayedPayoutTx {
|
||||
|
||||
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) {
|
||||
var delayedPayoutHashes = tradableList.stream()
|
||||
.map(trade -> new DelayedPayoutHash(trade.getId(),
|
||||
Utilities.bytesAsHexString(trade.getDelayedPayoutTxBytes())))
|
||||
.collect(Collectors.toList());
|
||||
jsonFileManager.writeToDisc(Utilities.objectToJson(delayedPayoutHashes), fileName);
|
||||
}
|
||||
|
||||
}
|
|
@ -66,7 +66,6 @@ import bisq.common.proto.network.NetworkEnvelope;
|
|||
import bisq.common.proto.persistable.PersistedDataHost;
|
||||
import bisq.common.storage.JsonFileManager;
|
||||
import bisq.common.storage.Storage;
|
||||
import bisq.common.util.Utilities;
|
||||
|
||||
import org.bitcoinj.core.AddressFormatException;
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
@ -247,7 +246,10 @@ public class TradeManager implements PersistedDataHost {
|
|||
if (offer != null)
|
||||
offer.setPriceFeedService(priceFeedService);
|
||||
});
|
||||
maybeDumpDelayedPayoutTxs();
|
||||
|
||||
if (dumpDelayedPayoutTxs){
|
||||
DumpDelayedPayoutTx.dumpDelayedPayoutTxs(tradableList, jsonFileManager, "delayed_payout_txs");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -793,25 +795,4 @@ public class TradeManager implements PersistedDataHost {
|
|||
public void persistTrades() {
|
||||
tradableList.persist();
|
||||
}
|
||||
|
||||
@SuppressWarnings("InnerClassMayBeStatic")
|
||||
class DelayedPayoutHash {
|
||||
String tradeId;
|
||||
String delayedPayoutTx;
|
||||
DelayedPayoutHash(String tradeId, String delayedPayoutTx) {
|
||||
this.tradeId = tradeId;
|
||||
this.delayedPayoutTx = delayedPayoutTx;
|
||||
}
|
||||
}
|
||||
|
||||
private void maybeDumpDelayedPayoutTxs() {
|
||||
if (!dumpDelayedPayoutTxs)
|
||||
return;
|
||||
|
||||
var delayedPayoutHashes = tradableList.stream()
|
||||
.map(trade -> new DelayedPayoutHash(trade.getId(),
|
||||
Utilities.bytesAsHexString(trade.getDelayedPayoutTxBytes())))
|
||||
.collect(Collectors.toList());
|
||||
jsonFileManager.writeToDisc(Utilities.objectToJson(delayedPayoutHashes), "delayed_payout_txs");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue