mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 23:18:17 +01:00
Block on tx-fee-request in core TakeOfferModel init
Added license comment too.
This commit is contained in:
parent
9e76f5fdc3
commit
cb65de6d2e
1 changed files with 32 additions and 6 deletions
|
@ -1,3 +1,20 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Bisq.
|
||||||
|
*
|
||||||
|
* Bisq is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package bisq.core.offer.takeoffer;
|
package bisq.core.offer.takeoffer;
|
||||||
|
|
||||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||||
|
@ -20,6 +37,8 @@ import org.bitcoinj.core.Coin;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -141,12 +160,19 @@ public class TakeOfferModel implements Model {
|
||||||
// Payout tx: 371 bytes
|
// Payout tx: 371 bytes
|
||||||
// Disputed payout tx: 408 bytes
|
// Disputed payout tx: 408 bytes
|
||||||
|
|
||||||
// Request actual fees:
|
txFeePerByteFromFeeService = getTxFeePerByte();
|
||||||
log.info("Start requestTxFee: txFeeFromFeeService={}", txFeeFromFeeService);
|
txFeeFromFeeService = offerUtil.getTxFeeBySize(txFeePerByteFromFeeService, feeTxSize);
|
||||||
feeService.requestFees(() -> {
|
log.info("{} txFeePerByte = {}", feeService.getClass().getSimpleName(), txFeePerByteFromFeeService);
|
||||||
txFeePerByteFromFeeService = feeService.getTxFeePerByte();
|
}
|
||||||
txFeeFromFeeService = offerUtil.getTxFeeBySize(txFeePerByteFromFeeService, feeTxSize);
|
|
||||||
});
|
private Coin getTxFeePerByte() {
|
||||||
|
try {
|
||||||
|
CompletableFuture<Void> feeRequestFuture = CompletableFuture.runAsync(feeService::requestFees);
|
||||||
|
feeRequestFuture.get(); // Block until async fee request is complete.
|
||||||
|
return feeService.getTxFeePerByte();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
throw new IllegalStateException("Could not request fees from fee service.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateTotalToPay() {
|
private void calculateTotalToPay() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue