Refactoring: Extract requestPersistence method

This commit is contained in:
chimp1984 2020-11-18 12:12:59 -05:00
parent fa0c28adf6
commit 9517f427b6
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
3 changed files with 19 additions and 7 deletions

View File

@ -84,13 +84,13 @@ public class ClosedTradableManager implements PersistedDataHost {
public void add(Tradable tradable) {
if (closedTradables.add(tradable)) {
persistenceManager.requestPersistence();
requestPersistence();
}
}
public void remove(Tradable tradable) {
if (closedTradables.remove(tradable)) {
persistenceManager.requestPersistence();
requestPersistence();
}
}
@ -117,4 +117,8 @@ public class ClosedTradableManager implements PersistedDataHost {
return getClosedTrades().stream()
.filter(Trade::isFundsLockedIn);
}
private void requestPersistence() {
persistenceManager.requestPersistence();
}
}

View File

@ -95,13 +95,13 @@ public class FailedTradesManager implements PersistedDataHost {
public void add(Trade trade) {
if (failedTrades.add(trade)) {
persistenceManager.requestPersistence();
requestPersistence();
}
}
public void removeTrade(Trade trade) {
if (failedTrades.remove(trade)) {
persistenceManager.requestPersistence();
requestPersistence();
}
}
@ -129,7 +129,7 @@ public class FailedTradesManager implements PersistedDataHost {
if (unFailTradeCallback.apply(trade)) {
log.info("Unfailing trade {}", trade.getId());
if (failedTrades.remove(trade)) {
persistenceManager.requestPersistence();
requestPersistence();
}
}
}
@ -151,4 +151,8 @@ public class FailedTradesManager implements PersistedDataHost {
}
return blockingTrades.toString();
}
private void requestPersistence() {
persistenceManager.requestPersistence();
}
}

View File

@ -536,7 +536,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
mailboxItemsByUid.putIfAbsent(uid, new ArrayList<>());
mailboxItemsByUid.get(uid).add(mailboxItem);
mailboxMessageList.add(mailboxItem);
persistenceManager.requestPersistence();
requestPersistence();
NodeAddress sender = mailboxMessage.getSenderNodeAddress();
log.info("Received a {} mailbox message with uid {} and senderAddress {}",
@ -818,7 +818,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
mailboxMessageList.remove(mailboxItem);
});
mailboxItemsByUid.remove(uid);
persistenceManager.requestPersistence();
requestPersistence();
}
});
} else {
@ -827,6 +827,10 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
}
}
private void requestPersistence() {
persistenceManager.requestPersistence();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Data storage