mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +01:00
Dont call local storage if we read from persisted object
This commit is contained in:
parent
2d24fb7ed1
commit
849ab100c3
2 changed files with 8 additions and 6 deletions
|
@ -239,7 +239,7 @@ public class TradeManager {
|
|||
trade.getDate(),
|
||||
(trade.getDepositTx() != null ? trade.getDepositTx().getHashAsString() : ""),
|
||||
keyRing.getPubKeyRing());
|
||||
tradeStatisticsManager.add(tradeStatistics);
|
||||
tradeStatisticsManager.add(tradeStatistics, true);
|
||||
|
||||
// We only republish trades from last 10 days
|
||||
// TODO check if needed at all. Don't want to remove it atm to not risk anything.
|
||||
|
|
|
@ -69,14 +69,14 @@ public class TradeStatisticsManager {
|
|||
|
||||
HashSet<TradeStatistics> persisted = statisticsStorage.initAndGetPersistedWithFileName("TradeStatistics");
|
||||
if (persisted != null)
|
||||
persisted.stream().forEach(this::add);
|
||||
persisted.stream().forEach(e -> add(e, false));
|
||||
|
||||
p2PService.addHashSetChangedListener(new HashMapChangedListener() {
|
||||
@Override
|
||||
public void onAdded(ProtectedStorageEntry data) {
|
||||
final StoragePayload storagePayload = data.getStoragePayload();
|
||||
if (storagePayload instanceof TradeStatistics)
|
||||
add((TradeStatistics) storagePayload);
|
||||
add((TradeStatistics) storagePayload, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,17 +89,19 @@ public class TradeStatisticsManager {
|
|||
p2PService.getP2PDataStorage().getMap().values().forEach(e -> {
|
||||
final StoragePayload storagePayload = e.getStoragePayload();
|
||||
if (storagePayload instanceof TradeStatistics)
|
||||
add((TradeStatistics) storagePayload);
|
||||
add((TradeStatistics) storagePayload, false);
|
||||
});
|
||||
}
|
||||
|
||||
public void add(TradeStatistics tradeStatistics) {
|
||||
public void add(TradeStatistics tradeStatistics, boolean storeLocally) {
|
||||
if (!tradeStatisticsSet.contains(tradeStatistics)) {
|
||||
boolean itemAlreadyAdded = tradeStatisticsSet.stream().filter(e -> (e.getOfferId().equals(tradeStatistics.getOfferId()))).findAny().isPresent();
|
||||
if (!itemAlreadyAdded) {
|
||||
tradeStatisticsSet.add(tradeStatistics);
|
||||
observableTradeStatisticsSet.add(tradeStatistics);
|
||||
statisticsStorage.queueUpForSave(new HashSet<>(tradeStatisticsSet), 2000);
|
||||
|
||||
if (storeLocally)
|
||||
statisticsStorage.queueUpForSave(new HashSet<>(tradeStatisticsSet), 2000);
|
||||
|
||||
dump();
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue