use of io.bitsquare.trade.protocol.availability.OfferAvailabilityModel in project bitsquare by bitsquare.
the class Offer method checkOfferAvailability.
///////////////////////////////////////////////////////////////////////////////////////////
// Availability
///////////////////////////////////////////////////////////////////////////////////////////
public void checkOfferAvailability(OfferAvailabilityModel model, ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
availabilityProtocol = new OfferAvailabilityProtocol(model, () -> {
cancelAvailabilityRequest();
resultHandler.handleResult();
}, (errorMessage) -> {
if (availabilityProtocol != null)
availabilityProtocol.cancel();
log.error(errorMessage);
errorMessageHandler.handleErrorMessage(errorMessage);
});
availabilityProtocol.sendOfferAvailabilityRequest();
}
use of io.bitsquare.trade.protocol.availability.OfferAvailabilityModel in project bitsquare by bitsquare.
the class TradeManager method onTakeOffer.
// First we check if offer is still available then we create the trade with the protocol
public void onTakeOffer(Coin amount, long tradePrice, Coin fundsNeededForTrade, Offer offer, String paymentAccountId, boolean useSavingsWallet, TradeResultHandler tradeResultHandler, ErrorMessageHandler errorMessageHandler) {
final OfferAvailabilityModel model = getOfferAvailabilityModel(offer);
offer.checkOfferAvailability(model, () -> {
if (offer.getState() == Offer.State.AVAILABLE)
createTrade(amount, tradePrice, fundsNeededForTrade, offer, paymentAccountId, useSavingsWallet, model, tradeResultHandler);
}, errorMessageHandler::handleErrorMessage);
}
Aggregations