mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-01 13:04:40 -04:00
incease fee as testnet is spammed with tx with high fees. use FxTimer in fx classes (gui). Use scheduledExecutor instead of timer
This commit is contained in:
parent
8716a506e8
commit
e456883f9b
19 changed files with 176 additions and 175 deletions
|
@ -21,6 +21,7 @@ import ch.qos.logback.classic.Logger;
|
|||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import io.bitsquare.alert.AlertManager;
|
||||
import io.bitsquare.arbitration.ArbitratorManager;
|
||||
import io.bitsquare.btc.WalletService;
|
||||
import io.bitsquare.common.UserThread;
|
||||
import io.bitsquare.common.handlers.ResultHandler;
|
||||
|
@ -303,6 +304,8 @@ public class BitsquareApp extends Application {
|
|||
log.debug("gracefulShutDown");
|
||||
try {
|
||||
if (injector != null) {
|
||||
ArbitratorManager arbitratorManager = injector.getInstance(ArbitratorManager.class);
|
||||
arbitratorManager.shutDown();
|
||||
OpenOfferManager openOfferManager = injector.getInstance(OpenOfferManager.class);
|
||||
openOfferManager.shutDown(() -> {
|
||||
P2PService p2PService = injector.getInstance(P2PService.class);
|
||||
|
|
|
@ -68,10 +68,6 @@ import java.util.stream.Stream;
|
|||
class MainViewModel implements ViewModel {
|
||||
private static final Logger log = LoggerFactory.getLogger(MainViewModel.class);
|
||||
|
||||
private static final long BLOCKCHAIN_SYNC_TIMEOUT = 60000;
|
||||
private static final long LOST_P2P_CONNECTION_TIMEOUT = 5000;
|
||||
// private static final long LOST_BTC_CONNECTION_TIMEOUT = 5000;
|
||||
|
||||
private final WalletService walletService;
|
||||
private final TradeWalletService tradeWalletService;
|
||||
private final ArbitratorManager arbitratorManager;
|
||||
|
@ -111,12 +107,10 @@ class MainViewModel implements ViewModel {
|
|||
private final String btcNetworkAsString;
|
||||
|
||||
|
||||
private Timer blockchainSyncTimeoutTimer;
|
||||
private Timer lostP2PConnectionTimeoutTimer;
|
||||
private MonadicBinding<Boolean> allServicesDone;
|
||||
private User user;
|
||||
private int numBTCPeers = 0;
|
||||
//private Timer lostBTCConnectionTimeoutTimer;
|
||||
private Timer checkForBtcSyncStateTimer;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -130,7 +124,6 @@ class MainViewModel implements ViewModel {
|
|||
User user, AlertManager alertManager, WalletPasswordPopup walletPasswordPopup,
|
||||
BSFormatter formatter) {
|
||||
this.user = user;
|
||||
log.debug("in");
|
||||
this.walletService = walletService;
|
||||
this.tradeWalletService = tradeWalletService;
|
||||
this.arbitratorManager = arbitratorManager;
|
||||
|
@ -164,7 +157,7 @@ class MainViewModel implements ViewModel {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void initializeAllServices() {
|
||||
log.trace("initializeAllServices");
|
||||
Log.traceCall();
|
||||
|
||||
BooleanProperty walletInitialized = initBitcoinWallet();
|
||||
BooleanProperty p2pNetWorkReady = initP2PNetwork();
|
||||
|
@ -232,9 +225,6 @@ class MainViewModel implements ViewModel {
|
|||
}
|
||||
|
||||
private BooleanProperty initBitcoinWallet() {
|
||||
if (walletService.downloadPercentageProperty().get() > -1)
|
||||
startBlockchainSyncTimeout();
|
||||
|
||||
EasyBind.subscribe(walletService.downloadPercentageProperty(), newValue -> setBitcoinNetworkSyncProgress((double) newValue));
|
||||
|
||||
walletService.numPeersProperty().addListener((observable, oldValue, newValue) -> {
|
||||
|
@ -258,8 +248,7 @@ class MainViewModel implements ViewModel {
|
|||
}
|
||||
|
||||
private void onAllServicesInitialized() {
|
||||
log.trace("onAllServicesInitialized");
|
||||
|
||||
Log.traceCall();
|
||||
|
||||
// disputeManager
|
||||
disputeManager.getDisputesAsObservableList().addListener((ListChangeListener<Dispute>) change -> {
|
||||
|
@ -318,8 +307,9 @@ class MainViewModel implements ViewModel {
|
|||
}
|
||||
});
|
||||
updateBalance();
|
||||
setBitcoinNetworkSyncProgress(walletService.downloadPercentageProperty().get());
|
||||
|
||||
setBitcoinNetworkSyncProgress(walletService.downloadPercentageProperty().get());
|
||||
checkPeriodicallyForBtcSyncState();
|
||||
|
||||
// openOfferManager
|
||||
openOfferManager.getOpenOffers().addListener((ListChangeListener<OpenOffer>) c -> updateBalance());
|
||||
|
@ -364,6 +354,19 @@ class MainViewModel implements ViewModel {
|
|||
showAppScreen.set(true);
|
||||
}
|
||||
|
||||
private void checkPeriodicallyForBtcSyncState() {
|
||||
if (walletService.downloadPercentageProperty().get() == -1) {
|
||||
checkForBtcSyncStateTimer = FxTimer.runPeriodically(Duration.ofSeconds(10),
|
||||
() -> {
|
||||
log.info("Bitcoin blockchain sync still not started.");
|
||||
setBitcoinNetworkSyncProgress(walletService.downloadPercentageProperty().get());
|
||||
}
|
||||
);
|
||||
} else {
|
||||
stopCheckForBtcSyncStateTimer();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateP2pNetworkInfoWithPeersChanged(int numAuthenticatedPeers) {
|
||||
p2PNetworkInfo.set("Nr. of connections: " + numAuthenticatedPeers);
|
||||
}
|
||||
|
@ -566,40 +569,27 @@ class MainViewModel implements ViewModel {
|
|||
btcSyncProgress.set(value);
|
||||
String numPeers = "Nr. of peers: " + numBTCPeers;
|
||||
if (value == 1) {
|
||||
stopBlockchainSyncTimeout();
|
||||
btcSplashInfo.set(numPeers + " / synchronized with " + btcNetworkAsString);
|
||||
btcFooterInfo.set(numPeers + " / synchronized with " + btcNetworkAsString);
|
||||
btcSplashSyncIconId.set("image-connection-synced");
|
||||
stopCheckForBtcSyncStateTimer();
|
||||
} else if (value > 0.0) {
|
||||
// We stop as soon the download started the timeout
|
||||
stopBlockchainSyncTimeout();
|
||||
|
||||
String percentage = formatter.formatToPercent(value);
|
||||
btcSplashInfo.set(numPeers + " / synchronizing with " + btcNetworkAsString + ": " + percentage);
|
||||
btcFooterInfo.set(numPeers + " / synchronizing " + btcNetworkAsString + ": " + percentage);
|
||||
|
||||
stopCheckForBtcSyncStateTimer();
|
||||
} else if (value == -1) {
|
||||
// not ready yet
|
||||
btcSplashInfo.set(numPeers + " / connecting to " + btcNetworkAsString);
|
||||
btcFooterInfo.set(numPeers + " / connecting to " + btcNetworkAsString);
|
||||
} else {
|
||||
log.error("Not allowed value at setBitcoinNetworkSyncProgress: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
private void startBlockchainSyncTimeout() {
|
||||
log.trace("startBlockchainSyncTimeout");
|
||||
stopBlockchainSyncTimeout();
|
||||
|
||||
blockchainSyncTimeoutTimer = FxTimer.runLater(Duration.ofMillis(BLOCKCHAIN_SYNC_TIMEOUT), () -> {
|
||||
log.trace("Timeout reached");
|
||||
setWalletServiceException(new TimeoutException());
|
||||
});
|
||||
}
|
||||
|
||||
private void stopBlockchainSyncTimeout() {
|
||||
if (blockchainSyncTimeoutTimer != null) {
|
||||
log.trace("stopBlockchainSyncTimeout");
|
||||
blockchainSyncTimeoutTimer.stop();
|
||||
blockchainSyncTimeoutTimer = null;
|
||||
private void stopCheckForBtcSyncStateTimer() {
|
||||
if (checkForBtcSyncStateTimer != null) {
|
||||
checkForBtcSyncStateTimer.stop();
|
||||
checkForBtcSyncStateTimer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package io.bitsquare.gui.main.offer.createoffer;
|
|||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
import io.bitsquare.app.BitsquareApp;
|
||||
import io.bitsquare.common.UserThread;
|
||||
import io.bitsquare.common.util.Tuple2;
|
||||
import io.bitsquare.common.util.Tuple3;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
|
@ -57,9 +56,10 @@ import javafx.scene.text.Font;
|
|||
import javafx.stage.Window;
|
||||
import javafx.util.StringConverter;
|
||||
import org.controlsfx.control.PopOver;
|
||||
import org.reactfx.util.FxTimer;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.time.Duration;
|
||||
|
||||
import static io.bitsquare.gui.util.FormBuilder.*;
|
||||
import static javafx.beans.binding.Bindings.createStringBinding;
|
||||
|
@ -432,19 +432,21 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
|||
}
|
||||
|
||||
if (newValue) {
|
||||
UserThread.runAfter(() -> {
|
||||
new Popup().headLine(BSResources.get("createOffer.success.headline"))
|
||||
.message(BSResources.get("createOffer.success.info"))
|
||||
.actionButtonText("Go to \"Open offers\"")
|
||||
.onAction(() -> {
|
||||
close();
|
||||
UserThread.runAfter(() ->
|
||||
navigation.navigateTo(MainView.class, PortfolioView.class, OpenOffersView.class),
|
||||
100, TimeUnit.MILLISECONDS);
|
||||
})
|
||||
.onClose(() -> close())
|
||||
.show();
|
||||
}, 100, TimeUnit.MILLISECONDS);
|
||||
FxTimer.runLater(Duration.ofMillis(100),
|
||||
() -> {
|
||||
new Popup().headLine(BSResources.get("createOffer.success.headline"))
|
||||
.message(BSResources.get("createOffer.success.info"))
|
||||
.actionButtonText("Go to \"Open offers\"")
|
||||
.onAction(() -> {
|
||||
close();
|
||||
FxTimer.runLater(Duration.ofMillis(100),
|
||||
() -> navigation.navigateTo(MainView.class, PortfolioView.class, OpenOffersView.class)
|
||||
);
|
||||
})
|
||||
.onClose(() -> close())
|
||||
.show();
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
|||
@Override
|
||||
protected void activate() {
|
||||
if (BitsquareApp.DEV_MODE) {
|
||||
amount.set("0.0001");
|
||||
amount.set("0.01");
|
||||
minAmount.set(amount.get());
|
||||
price.set("400");
|
||||
volume.set("0.04");
|
||||
|
|
|
@ -20,7 +20,6 @@ package io.bitsquare.gui.main.offer.takeoffer;
|
|||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
import io.bitsquare.app.BitsquareApp;
|
||||
import io.bitsquare.common.UserThread;
|
||||
import io.bitsquare.common.util.Tuple2;
|
||||
import io.bitsquare.common.util.Tuple3;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
|
@ -60,11 +59,12 @@ import org.controlsfx.control.action.Action;
|
|||
import org.controlsfx.dialog.Dialog;
|
||||
import org.fxmisc.easybind.EasyBind;
|
||||
import org.fxmisc.easybind.Subscription;
|
||||
import org.reactfx.util.FxTimer;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static io.bitsquare.gui.util.FormBuilder.*;
|
||||
import static javafx.beans.binding.Bindings.createStringBinding;
|
||||
|
@ -223,18 +223,20 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
|
|||
}
|
||||
|
||||
if (newValue && model.getTrade() != null && model.getTrade().errorMessageProperty().get() == null) {
|
||||
UserThread.runAfter(() -> {
|
||||
new Popup().information(BSResources.get("takeOffer.success.info"))
|
||||
.actionButtonText("Go to \"Open trades\"")
|
||||
.onAction(() -> {
|
||||
close();
|
||||
UserThread.runAfter(() ->
|
||||
navigation.navigateTo(MainView.class, PortfolioView.class, PendingTradesView.class),
|
||||
100, TimeUnit.MILLISECONDS);
|
||||
})
|
||||
.onClose(() -> close())
|
||||
.show();
|
||||
}, 100, TimeUnit.MILLISECONDS);
|
||||
FxTimer.runLater(Duration.ofMillis(100),
|
||||
() -> {
|
||||
new Popup().information(BSResources.get("takeOffer.success.info"))
|
||||
.actionButtonText("Go to \"Open trades\"")
|
||||
.onAction(() -> {
|
||||
close();
|
||||
FxTimer.runLater(Duration.ofMillis(100),
|
||||
() -> navigation.navigateTo(MainView.class, PortfolioView.class, PendingTradesView.class)
|
||||
);
|
||||
})
|
||||
.onClose(() -> close())
|
||||
.show();
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -44,8 +44,10 @@ import javafx.scene.control.TextField;
|
|||
import javafx.scene.layout.GridPane;
|
||||
import javafx.util.StringConverter;
|
||||
import org.bitcoinj.core.Peer;
|
||||
import org.reactfx.util.FxTimer;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -206,7 +208,7 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
|
|||
"Do you want to shut down now?")
|
||||
.onAction(() -> {
|
||||
preferences.setBitcoinNetwork(netWorkComboBox.getSelectionModel().getSelectedItem());
|
||||
UserThread.runAfter(() -> BitsquareApp.shutDownHandler.run(), 1);
|
||||
FxTimer.runLater(Duration.ofMillis(500), () -> BitsquareApp.shutDownHandler.run());
|
||||
})
|
||||
.actionButtonText("Shut down")
|
||||
.closeButtonText("Cancel")
|
||||
|
|
|
@ -32,6 +32,7 @@ import javafx.scene.layout.HBox;
|
|||
import org.bitcoinj.core.AddressFormatException;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.InsufficientMoneyException;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.reactfx.util.FxTimer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -41,6 +42,7 @@ import javax.inject.Inject;
|
|||
import java.time.Duration;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static io.bitsquare.gui.util.FormBuilder.*;
|
||||
|
||||
public class EmptyWalletPopup extends Popup {
|
||||
|
@ -94,7 +96,9 @@ public class EmptyWalletPopup extends Popup {
|
|||
10);
|
||||
|
||||
Coin totalBalance = walletService.getAvailableBalance();
|
||||
boolean isBalanceSufficient = totalBalance.compareTo(FeePolicy.TX_FEE) >= 0;
|
||||
checkArgument(totalBalance.compareTo(FeePolicy.TX_FEE.add(Transaction.MIN_NONDUST_OUTPUT)) > 0,
|
||||
"You cannot send an amount which are smaller than the fee + dust output.");
|
||||
boolean isBalanceSufficient = totalBalance.compareTo(FeePolicy.TX_FEE.add(Transaction.MIN_NONDUST_OUTPUT)) > 0;
|
||||
addressTextField = addLabelTextField(gridPane, ++rowIndex, "Your available wallet balance:",
|
||||
formatter.formatCoinWithCode(totalBalance), 10).second;
|
||||
Tuple2<Label, InputTextField> tuple = addLabelInputTextField(gridPane, ++rowIndex, "Your destination address:");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue