Add more requestPersistence for data changes in ProcessModel and TradingPeer

This commit is contained in:
chimp1984 2020-11-18 12:38:39 -05:00
parent 9517f427b6
commit 255460e5d5
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
16 changed files with 34 additions and 2 deletions

View File

@ -204,9 +204,9 @@ public final class MediationManager extends DisputeManager<MediationDisputeList>
trade.getDisputeState() == Trade.DisputeState.MEDIATION_STARTED_BY_PEER) {
trade.getProcessModel().setBuyerPayoutAmountFromMediation(disputeResult.getBuyerPayoutAmount().value);
trade.getProcessModel().setSellerPayoutAmountFromMediation(disputeResult.getSellerPayoutAmount().value);
tradeManager.requestPersistence();
trade.setDisputeState(Trade.DisputeState.MEDIATION_CLOSED);
tradeManager.requestPersistence();
}
} else {

View File

@ -433,6 +433,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
((TakerProtocol) tradeProtocol).onTakeOffer();
tradeResultHandler.handleResult(trade);
requestPersistence();
}
},
errorMessageHandler);

View File

@ -65,6 +65,7 @@ public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol
Offer offer = checkNotNull(trade.getOffer());
processModel.getTradingPeer().setPubKeyRing(offer.getPubKeyRing());
processModel.getTradeManager().requestPersistence();
}
@ -83,7 +84,10 @@ public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol
BuyerAsTakerCreatesDepositTxInputs.class,
TakerSendInputsForDepositTxRequest.class)
.withTimeout(30))
.run(() -> processModel.setTempTradingPeerNodeAddress(trade.getTradingPeerNodeAddress()))
.run(() -> {
processModel.setTempTradingPeerNodeAddress(trade.getTradingPeerNodeAddress());
processModel.getTradeManager().requestPersistence();
})
.executeTasks();
}

View File

@ -99,11 +99,13 @@ public class FluentProtocol {
NodeAddress peer = condition.getPeer();
if (peer != null) {
tradeProtocol.processModel.setTempTradingPeerNodeAddress(peer);
tradeProtocol.processModel.getTradeManager().requestPersistence();
}
TradeMessage message = condition.getMessage();
if (message != null) {
tradeProtocol.processModel.setTradeMessage(message);
tradeProtocol.processModel.getTradeManager().requestPersistence();
}
TradeTaskRunner taskRunner = setup.getTaskRunner(message, condition.getEvent());

View File

@ -294,6 +294,7 @@ public class ProcessModel implements Model, PersistablePayload {
public void setPaymentStartedMessageState(MessageState paymentStartedMessageStateProperty) {
this.paymentStartedMessageStateProperty.set(paymentStartedMessageStateProperty);
tradeManager.requestPersistence();
}
void setDepositTxSentAckMessage(AckMessage ackMessage) {
@ -305,6 +306,7 @@ public class ProcessModel implements Model, PersistablePayload {
public void setDepositTxMessageState(MessageState messageState) {
this.depositTxMessageStateProperty.set(messageState);
tradeManager.requestPersistence();
}
void witnessDebugLog(Trade trade) {

View File

@ -59,6 +59,7 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc
super(trade);
Offer offer = checkNotNull(trade.getOffer());
processModel.getTradingPeer().setPubKeyRing(offer.getPubKeyRing());
processModel.getTradeManager().requestPersistence();
}

View File

@ -81,6 +81,8 @@ public class BuyerSignPayoutTx extends TradeTask {
sellerMultiSigPubKey);
processModel.setPayoutTxSignature(payoutTxSignature);
processModel.getTradeManager().requestPersistence();
complete();
} catch (Throwable t) {
failed(t);

View File

@ -69,6 +69,8 @@ public class BuyerSignsDelayedPayoutTx extends TradeTask {
sellerMultiSigPubKey);
processModel.setDelayedPayoutTxSignature(delayedPayoutTxSignature);
processModel.getTradeManager().requestPersistence();
complete();
} catch (Throwable t) {
failed(t);

View File

@ -97,6 +97,8 @@ public class BuyerAsMakerCreatesAndSignsDepositTx extends TradeTask {
processModel.setPreparedDepositTx(result.depositTransaction);
processModel.setRawTransactionInputs(result.rawMakerInputs);
processModel.getTradeManager().requestPersistence();
complete();
} catch (Throwable t) {
failed(t);

View File

@ -53,6 +53,8 @@ public class BuyerAsTakerCreatesDepositTxInputs extends TradeTask {
processModel.setChangeOutputValue(result.changeOutputValue);
processModel.setChangeOutputAddress(result.changeOutputAddress);
processModel.getTradeManager().requestPersistence();
complete();
} catch (Throwable t) {
failed(t);

View File

@ -99,6 +99,8 @@ public class SignMediatedPayoutTx extends TradeTask {
sellerMultiSigPubKey);
processModel.setMediatedPayoutTxSignature(mediatedPayoutTxSignature);
processModel.getTradeManager().requestPersistence();
complete();
} catch (Throwable t) {
failed(t);

View File

@ -56,6 +56,8 @@ public class SellerCreatesDelayedPayoutTx extends TradeTask {
processModel.setPreparedDelayedPayoutTx(preparedDelayedPayoutTx);
processModel.getTradeManager().requestPersistence();
complete();
} catch (Throwable t) {
failed(t);

View File

@ -70,6 +70,8 @@ public class SellerSignsDelayedPayoutTx extends TradeTask {
processModel.setDelayedPayoutTxSignature(delayedPayoutTxSignature);
processModel.getTradeManager().requestPersistence();
complete();
} catch (Throwable t) {
failed(t);

View File

@ -57,6 +57,8 @@ public class SellerAsTakerCreatesDepositTxInputs extends TradeTask {
processModel.setChangeOutputValue(result.changeOutputValue);
processModel.setChangeOutputAddress(result.changeOutputAddress);
processModel.getTradeManager().requestPersistence();
complete();
} catch (Throwable t) {
failed(t);

View File

@ -100,6 +100,9 @@ public class CreateTakerFeeTx extends TradeTask {
processModel.setTakeOfferFeeTx(transaction);
walletService.swapTradeEntryToAvailableEntry(id, AddressEntry.Context.OFFER_FUNDING);
processModel.getTradeManager().requestPersistence();
complete();
} catch (Throwable t) {
if (t instanceof DaoDisabledException) {

View File

@ -129,6 +129,9 @@ public class TakerSendInputsForDepositTxRequest extends TradeTask {
log.info("Send {} with offerId {} and uid {} to peer {}",
request.getClass().getSimpleName(), request.getTradeId(),
request.getUid(), trade.getTradingPeerNodeAddress());
processModel.getTradeManager().requestPersistence();
processModel.getP2PService().sendEncryptedDirectMessage(
trade.getTradingPeerNodeAddress(),
processModel.getTradingPeer().getPubKeyRing(),