avoid persisting when maybe sending deposits confirmed message
This commit is contained in:
parent
870630b381
commit
c197ffb282
@ -413,6 +413,11 @@ public class PersistenceManager<T extends PersistableEnvelope> {
|
||||
public void requestPersistence() {
|
||||
if (flushAtShutdownCalled) {
|
||||
log.warn("We have started the shut down routine already. We ignore that requestPersistence call.");
|
||||
try {
|
||||
throw new RuntimeException("We have started the shut down routine already. We ignore that requestPersistence call.");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1359,6 +1359,15 @@ public abstract class Trade implements Tradable, Model {
|
||||
throw new RuntimeException("Trade is not maker, taker, or arbitrator");
|
||||
}
|
||||
|
||||
private List<TradePeer> getPeers() {
|
||||
List<TradePeer> peers = new ArrayList<TradePeer>();
|
||||
peers.add(getMaker());
|
||||
peers.add(getTaker());
|
||||
peers.add(getArbitrator());
|
||||
if (!peers.remove(getSelf())) throw new IllegalStateException("Failed to remove self from list of peers");
|
||||
return peers;
|
||||
}
|
||||
|
||||
public TradePeer getArbitrator() {
|
||||
return processModel.getArbitrator();
|
||||
}
|
||||
@ -1522,6 +1531,16 @@ public abstract class Trade implements Tradable, Model {
|
||||
return isDepositsPublished() && getState().getPhase().ordinal() >= Phase.DEPOSITS_CONFIRMED.ordinal();
|
||||
}
|
||||
|
||||
// TODO: hacky way to check for deposits confirmed acks, redundant with getDepositsConfirmedTasks()
|
||||
public boolean isDepositsConfirmedAcked() {
|
||||
if (this instanceof BuyerTrade) {
|
||||
return getArbitrator().isDepositsConfirmedMessageAcked();
|
||||
} else {
|
||||
for (TradePeer peer : getPeers()) if (!peer.isDepositsConfirmedMessageAcked()) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDepositsUnlocked() {
|
||||
return isDepositsPublished() && getState().getPhase().ordinal() >= Phase.DEPOSITS_UNLOCKED.ordinal();
|
||||
}
|
||||
|
@ -863,9 +863,9 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
|
||||
}
|
||||
|
||||
public void maybeSendDepositsConfirmedMessages() {
|
||||
if (trade.isShutDownStarted()) return;
|
||||
synchronized (trade) {
|
||||
if (!trade.isInitialized()) return; // skip if shutting down
|
||||
if (trade.isDepositsConfirmedAcked()) return;
|
||||
if (!trade.isInitialized() || trade.isShutDownStarted()) return; // skip if shutting down
|
||||
latchTrade();
|
||||
expect(new Condition(trade))
|
||||
.setup(tasks(getDepositsConfirmedTasks())
|
||||
|
Loading…
Reference in New Issue
Block a user