mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 15:26:03 -04:00
Set mainnet as default
This commit is contained in:
parent
495616edea
commit
d8086ffba9
@ -31,7 +31,7 @@ public enum BitcoinNetwork implements Serializable {
|
||||
REGTEST(RegTestParams.get());
|
||||
|
||||
public static final String KEY = "bitcoin.network";
|
||||
public static final BitcoinNetwork DEFAULT = TESTNET;
|
||||
public static final BitcoinNetwork DEFAULT = MAINNET;
|
||||
|
||||
private final NetworkParameters parameters;
|
||||
|
||||
|
@ -354,8 +354,8 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||
btcNetworkWarnMsgPopup = new Popup().warning(newValue).show();
|
||||
} else {
|
||||
btcInfoLabel.setId("footer-pane");
|
||||
if (p2PNetworkWarnMsgPopup != null)
|
||||
p2PNetworkWarnMsgPopup.hide();
|
||||
if (btcNetworkWarnMsgPopup != null)
|
||||
btcNetworkWarnMsgPopup.hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -27,6 +27,7 @@ import io.bitsquare.arbitration.ArbitratorManager;
|
||||
import io.bitsquare.arbitration.Dispute;
|
||||
import io.bitsquare.arbitration.DisputeManager;
|
||||
import io.bitsquare.btc.AddressEntry;
|
||||
import io.bitsquare.btc.BitcoinNetwork;
|
||||
import io.bitsquare.btc.TradeWalletService;
|
||||
import io.bitsquare.btc.WalletService;
|
||||
import io.bitsquare.btc.listeners.BalanceListener;
|
||||
@ -66,6 +67,7 @@ import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@ -100,7 +102,7 @@ public class MainViewModel implements ViewModel {
|
||||
final StringProperty p2PNetworkWarnMsg = new SimpleStringProperty();
|
||||
final StringProperty p2PNetworkIconId = new SimpleStringProperty();
|
||||
final BooleanProperty bootstrapComplete = new SimpleBooleanProperty();
|
||||
|
||||
|
||||
// software update
|
||||
final String version = "v." + Version.VERSION;
|
||||
|
||||
@ -381,14 +383,32 @@ public class MainViewModel implements ViewModel {
|
||||
"3. The user confirms that he has read and agreed to the rules defined in our " +
|
||||
"Wiki regrading the dispute process\n" +
|
||||
"(https://github.com/bitsquare/bitsquare/wiki/Arbitration-system).";
|
||||
if (!preferences.getTacAccepted() && !BitsquareApp.DEV_MODE)
|
||||
if (!preferences.getTacAccepted() && !BitsquareApp.DEV_MODE) {
|
||||
new Popup().headLine("USER AGREEMENT")
|
||||
.message(text)
|
||||
.actionButtonText("I agree")
|
||||
.closeButtonText("I disagree and quit")
|
||||
.onAction(() -> preferences.setTacAccepted(true))
|
||||
.onClose(() -> BitsquareApp.shutDownHandler.run())
|
||||
.onAction(() -> {
|
||||
preferences.setTacAccepted(true);
|
||||
if (preferences.getBitcoinNetwork() == BitcoinNetwork.MAINNET)
|
||||
UserThread.runAfter(() -> new Popup()
|
||||
.warning("The application is still in alpha version.\n" +
|
||||
"Please be aware that using Mainnet comes with the risk to lose funds in case of software bugs.\n" +
|
||||
"To limit the possible losses the maximum allowed trading amount and the security deposit are " +
|
||||
"reduced to 0.01 BTC for the alpha version on Mainnet.")
|
||||
.headLine("Important information!")
|
||||
.actionButtonText("I understand and want to stick with Mainnet")
|
||||
.closeButtonText("Restart and use Testnet")
|
||||
.onClose(() -> {
|
||||
UserThread.execute(() -> preferences.setBitcoinNetwork(BitcoinNetwork.TESTNET));
|
||||
UserThread.runAfter(BitsquareApp.shutDownHandler::run, 300, TimeUnit.MILLISECONDS);
|
||||
})
|
||||
.width(600)
|
||||
.show(), 300, TimeUnit.MILLISECONDS);
|
||||
})
|
||||
.onClose(BitsquareApp.shutDownHandler::run)
|
||||
.show();
|
||||
}
|
||||
|
||||
// update nr of peers in footer
|
||||
numConnectedPeersListener = (observable, oldValue, newValue) -> {
|
||||
|
@ -20,7 +20,6 @@ package io.bitsquare.gui.main.settings.network;
|
||||
import io.bitsquare.app.BitsquareApp;
|
||||
import io.bitsquare.btc.BitcoinNetwork;
|
||||
import io.bitsquare.btc.WalletService;
|
||||
import io.bitsquare.common.UserThread;
|
||||
import io.bitsquare.gui.common.model.Activatable;
|
||||
import io.bitsquare.gui.common.view.ActivatableViewAndModel;
|
||||
import io.bitsquare.gui.common.view.FxmlView;
|
||||
@ -193,22 +192,8 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
|
||||
}
|
||||
|
||||
private void onSelectNetwork() {
|
||||
if (netWorkComboBox.getSelectionModel().getSelectedItem() != preferences.getBitcoinNetwork()) {
|
||||
if (netWorkComboBox.getSelectionModel().getSelectedItem() == BitcoinNetwork.MAINNET) {
|
||||
new Popup().warning("The application is not sufficiently tested yet. " +
|
||||
"Please be aware that using Mainnet comes with the risk to lose funds in case of software bugs.\n" +
|
||||
"To limit the possible losses the maximum allowed trading amount and the security deposit are " +
|
||||
"reduced to 0.01 BTC on Mainnet.")
|
||||
.actionButtonText("I will stick with Testnet for now")
|
||||
.onAction(() -> UserThread.execute(() -> netWorkComboBox.getSelectionModel().select(preferences.getBitcoinNetwork())))
|
||||
.closeButtonText("I understand the risk and want to use Mainnet")
|
||||
.onClose(() -> selectNetwork())
|
||||
.width(800)
|
||||
.show();
|
||||
} else {
|
||||
selectNetwork();
|
||||
}
|
||||
}
|
||||
if (netWorkComboBox.getSelectionModel().getSelectedItem() != preferences.getBitcoinNetwork())
|
||||
selectNetwork();
|
||||
}
|
||||
|
||||
private void selectNetwork() {
|
||||
|
@ -329,7 +329,7 @@ public class Popup {
|
||||
closeHandlerOptional.ifPresent(closeHandler -> closeHandler.run());
|
||||
});
|
||||
|
||||
if (actionHandlerOptional.isPresent()) {
|
||||
if (actionHandlerOptional.isPresent() || actionButtonText != null) {
|
||||
actionButton = new Button(actionButtonText == null ? "Ok" : actionButtonText);
|
||||
actionButton.setDefaultButton(true);
|
||||
actionButton.requestFocus();
|
||||
|
@ -54,6 +54,6 @@ public class NodeAddress implements Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getFullAddress();
|
||||
return getFullAddress() + "\n";
|
||||
}
|
||||
}
|
||||
|
@ -476,7 +476,7 @@ public class Connection implements MessageListener {
|
||||
shutDownReason = ConnectionListener.Reason.RESET;
|
||||
} else if (e instanceof SocketTimeoutException || e instanceof TimeoutException) {
|
||||
shutDownReason = ConnectionListener.Reason.TIMEOUT;
|
||||
log.warn("TimeoutException at socket " + socket.toString());
|
||||
log.debug("TimeoutException at socket " + socket.toString());
|
||||
log.debug("connection={}" + this);
|
||||
} else if (e instanceof EOFException) {
|
||||
shutDownReason = ConnectionListener.Reason.PEER_DISCONNECTED;
|
||||
|
@ -75,7 +75,7 @@ public class PeerExchangeHandshake implements MessageListener {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void requestReportedPeers(NodeAddress nodeAddress, List<NodeAddress> remainingNodeAddresses) {
|
||||
Log.traceCall("nodeAddress=" + nodeAddress + " / remainingNodeAddresses=" + remainingNodeAddresses);
|
||||
Log.traceCall("nodeAddress=" + nodeAddress);
|
||||
checkNotNull(networkNode.getNodeAddress(), "My node address must not be null at requestReportedPeers");
|
||||
checkArgument(timeoutTimer == null, "requestData must not be called twice.");
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class PeerExchangeManager implements MessageListener, ConnectionListener
|
||||
remainingNodeAddresses.remove(nodeAddress);
|
||||
requestReportedPeers(nodeAddress, remainingNodeAddresses);
|
||||
|
||||
int delay = new Random().nextInt(60) + 60 * 4; // 4-5 min
|
||||
int delay = new Random().nextInt(60) + 60 * 3; // 3-4 min
|
||||
executor.scheduleAtFixedRate(() -> UserThread.execute(this::maintainConnections),
|
||||
delay, delay, TimeUnit.SECONDS);
|
||||
}
|
||||
@ -127,7 +127,7 @@ public class PeerExchangeManager implements MessageListener, ConnectionListener
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void requestReportedPeers(NodeAddress nodeAddress, List<NodeAddress> remainingNodeAddresses) {
|
||||
Log.traceCall("nodeAddress=" + nodeAddress + " / remainingNodeAddresses=" + remainingNodeAddresses);
|
||||
Log.traceCall("nodeAddress=" + nodeAddress);
|
||||
if (!peerExchangeHandshakeMap.containsKey(nodeAddress)) {
|
||||
PeerExchangeHandshake peerExchangeHandshake = new PeerExchangeHandshake(networkNode,
|
||||
peerManager,
|
||||
@ -192,17 +192,16 @@ public class PeerExchangeManager implements MessageListener, ConnectionListener
|
||||
connectToMorePeers();
|
||||
}
|
||||
|
||||
// Use all outbound connections older than 5 min. for updating reported peers and make sure we keep the connection alive
|
||||
// Use all outbound connections older than 4 min. for updating reported peers and make sure we keep the connection alive
|
||||
// Inbound connections should be maintained be the requesting peer
|
||||
confirmedConnections.stream()
|
||||
.filter(c -> c.getPeersNodeAddressOptional().isPresent() &&
|
||||
c instanceof OutboundConnection &&
|
||||
new Date().getTime() - c.getLastActivityDate().getTime() > 5 * 60 * 1000)
|
||||
new Date().getTime() - c.getLastActivityDate().getTime() > 4 * 60 * 1000)
|
||||
.forEach(c -> UserThread.runAfterRandomDelay(() -> {
|
||||
log.trace("Call requestReportedPeers from maintainConnections");
|
||||
requestReportedPeers(c.getPeersNodeAddressOptional().get(), new ArrayList<>());
|
||||
}
|
||||
, 3, 5));
|
||||
}, 3, 5));
|
||||
}
|
||||
|
||||
private void connectToMorePeers() {
|
||||
|
@ -83,8 +83,7 @@ public class PeerManager implements ConnectionListener, MessageListener {
|
||||
if (dbStorage != null) {
|
||||
HashSet<ReportedPeer> persistedPeers = dbStorage.initAndGetPersisted("persistedPeers");
|
||||
if (persistedPeers != null) {
|
||||
log.info("We have persisted reported peers. " +
|
||||
"\npersistedPeers=" + persistedPeers);
|
||||
log.info("We have persisted reported peers. persistedPeers.size()=" + persistedPeers.size());
|
||||
this.persistedPeers.addAll(persistedPeers);
|
||||
}
|
||||
}
|
||||
@ -237,7 +236,7 @@ public class PeerManager implements ConnectionListener, MessageListener {
|
||||
}
|
||||
|
||||
public void addToReportedPeers(HashSet<ReportedPeer> reportedPeersToAdd, Connection connection) {
|
||||
Log.traceCall("reportedPeersToAdd = " + reportedPeersToAdd);
|
||||
Log.traceCall();
|
||||
// we disconnect misbehaving nodes trying to send too many peers
|
||||
// reported peers include the connected peers which is normally max. 10 but we give some headroom
|
||||
// for safety
|
||||
|
@ -31,7 +31,7 @@ public final class GetPeersRequest extends PeerExchangeMessage implements Sender
|
||||
return "GetPeersRequest{" +
|
||||
"senderNodeAddress=" + senderNodeAddress +
|
||||
", requestNonce=" + nonce +
|
||||
", reportedPeers=" + reportedPeers +
|
||||
", reportedPeers.size()=" + reportedPeers.size() +
|
||||
super.toString() + "} ";
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ public final class GetPeersResponse extends PeerExchangeMessage {
|
||||
public String toString() {
|
||||
return "GetPeersResponse{" +
|
||||
"requestNonce=" + requestNonce +
|
||||
", reportedPeers=" + reportedPeers +
|
||||
", reportedPeers.size()=" + reportedPeers.size() +
|
||||
super.toString() + "} ";
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user