mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
create offer moved to domain
This commit is contained in:
parent
b7004d639c
commit
3290586994
@ -51,31 +51,12 @@ public class CreateOfferCoordinator
|
||||
this.faultHandler = faultHandler;
|
||||
|
||||
state = State.INIT;
|
||||
ValidateOffer.run(this::onOfferValidated, this::onFailed, walletFacade, offer);
|
||||
PayOfferFee.run(this::onOfferFeePaid, this::onFailed, walletFacade, offer);
|
||||
ValidateOffer.run(this::onOfferValidated, this::onFailed, offer);
|
||||
}
|
||||
|
||||
private void onOfferValidated()
|
||||
{
|
||||
|
||||
}
|
||||
public void recover(State lastState, String transactionId, PublishTransactionResultHandler resultHandler, FaultHandler faultHandler)
|
||||
{
|
||||
this.transactionId = transactionId;
|
||||
this.resultHandler = resultHandler;
|
||||
this.faultHandler = faultHandler;
|
||||
switch (lastState)
|
||||
{
|
||||
case INIT:
|
||||
PayOfferFee.run(this::onOfferFeePaid, this::onFailed, walletFacade, offer);
|
||||
break;
|
||||
case OFFER_FEE_PAID:
|
||||
PublishOfferToDHT.run(this::onOfferPublishedToDHT, this::onFailed, messageFacade, offer);
|
||||
break;
|
||||
case OFFER_PUBLISHED_TO_DHT:
|
||||
// should be impossible
|
||||
resultHandler.onResult(transactionId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void onOfferFeePaid(String transactionId)
|
||||
@ -101,6 +82,31 @@ public class CreateOfferCoordinator
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Recovery
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void recover(State lastState, String transactionId, PublishTransactionResultHandler resultHandler, FaultHandler faultHandler)
|
||||
{
|
||||
this.transactionId = transactionId;
|
||||
this.resultHandler = resultHandler;
|
||||
this.faultHandler = faultHandler;
|
||||
switch (lastState)
|
||||
{
|
||||
case INIT:
|
||||
PayOfferFee.run(this::onOfferFeePaid, this::onFailed, walletFacade, offer);
|
||||
break;
|
||||
case OFFER_FEE_PAID:
|
||||
PublishOfferToDHT.run(this::onOfferPublishedToDHT, this::onFailed, messageFacade, offer);
|
||||
break;
|
||||
case OFFER_PUBLISHED_TO_DHT:
|
||||
// should be impossible
|
||||
resultHandler.onResult(transactionId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getters for persisting state
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.bitsquare.trade.protocol.createoffer.tasks;
|
||||
|
||||
import io.bitsquare.trade.Offer;
|
||||
import io.bitsquare.trade.handlers.ErrorMessageHandler;
|
||||
import io.bitsquare.trade.handlers.FaultHandler;
|
||||
import io.bitsquare.trade.handlers.ResultHandler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -10,18 +10,18 @@ public class ValidateOffer
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(ValidateOffer.class);
|
||||
|
||||
public static void run(ResultHandler resultHandler, ErrorMessageHandler faultHandler, Offer offer)
|
||||
public static void run(ResultHandler resultHandler, FaultHandler faultHandler, Offer offer)
|
||||
{
|
||||
boolean isValid = offer.getAmount().isGreaterThan(offer.getAmount());
|
||||
|
||||
if (offer.getAmount().compareTo(offer.getMinAmount()) >= 0)
|
||||
{
|
||||
faultHandler.onFault("Offer validation failed: Min. amount is larger than amount.");
|
||||
faultHandler.onFault("Offer validation failed: Min. amount is larger than amount.", new Exception("Offer validation failed: Min. amount is larger than amount."));
|
||||
|
||||
}
|
||||
else if (offer.getAcceptedCountries() == null || offer.getAcceptedCountries().size() == 0)
|
||||
{
|
||||
faultHandler.onFault("Offer validation failed: No accepted countries are defined");
|
||||
faultHandler.onFault("Offer validation failed: No accepted countries are defined.", new Exception("Offer validation failed: No accepted countries are defined."));
|
||||
} //TODO...
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user