Search in sources :

Example 1 with PlaceOfferProtocol

use of io.bitsquare.trade.protocol.placeoffer.PlaceOfferProtocol in project bitsquare by bitsquare.

the class OpenOfferManager method placeOffer.

///////////////////////////////////////////////////////////////////////////////////////////
// API
///////////////////////////////////////////////////////////////////////////////////////////
public void placeOffer(Offer offer, Coin reservedFundsForOffer, boolean useSavingsWallet, TransactionResultHandler resultHandler) {
    PlaceOfferModel model = new PlaceOfferModel(offer, reservedFundsForOffer, useSavingsWallet, walletService, tradeWalletService, offerBookService, user);
    PlaceOfferProtocol placeOfferProtocol = new PlaceOfferProtocol(model, transaction -> {
        OpenOffer openOffer = new OpenOffer(offer, openOffersStorage);
        openOffers.add(openOffer);
        openOffersStorage.queueUpForSave();
        resultHandler.handleResult(transaction);
        if (!stopped) {
            startPeriodicRepublishOffersTimer();
            startPeriodicRefreshOffersTimer();
        } else {
            log.debug("We have stopped already. We ignore that placeOfferProtocol.placeOffer.onResult call.");
        }
    });
    placeOfferProtocol.placeOffer();
}
Also used : PlaceOfferProtocol(io.bitsquare.trade.protocol.placeoffer.PlaceOfferProtocol) PlaceOfferModel(io.bitsquare.trade.protocol.placeoffer.PlaceOfferModel)

Aggregations

PlaceOfferModel (io.bitsquare.trade.protocol.placeoffer.PlaceOfferModel)1 PlaceOfferProtocol (io.bitsquare.trade.protocol.placeoffer.PlaceOfferProtocol)1