Set mainnet as default

This commit is contained in:
Manfred Karrer 2016-01-27 22:28:09 +01:00
parent 495616edea
commit d8086ffba9
12 changed files with 42 additions and 39 deletions

View file

@ -31,7 +31,7 @@ public enum BitcoinNetwork implements Serializable {
REGTEST(RegTestParams.get()); REGTEST(RegTestParams.get());
public static final String KEY = "bitcoin.network"; public static final String KEY = "bitcoin.network";
public static final BitcoinNetwork DEFAULT = TESTNET; public static final BitcoinNetwork DEFAULT = MAINNET;
private final NetworkParameters parameters; private final NetworkParameters parameters;

View file

@ -354,8 +354,8 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
btcNetworkWarnMsgPopup = new Popup().warning(newValue).show(); btcNetworkWarnMsgPopup = new Popup().warning(newValue).show();
} else { } else {
btcInfoLabel.setId("footer-pane"); btcInfoLabel.setId("footer-pane");
if (p2PNetworkWarnMsgPopup != null) if (btcNetworkWarnMsgPopup != null)
p2PNetworkWarnMsgPopup.hide(); btcNetworkWarnMsgPopup.hide();
} }
}); });

View file

@ -27,6 +27,7 @@ import io.bitsquare.arbitration.ArbitratorManager;
import io.bitsquare.arbitration.Dispute; import io.bitsquare.arbitration.Dispute;
import io.bitsquare.arbitration.DisputeManager; import io.bitsquare.arbitration.DisputeManager;
import io.bitsquare.btc.AddressEntry; import io.bitsquare.btc.AddressEntry;
import io.bitsquare.btc.BitcoinNetwork;
import io.bitsquare.btc.TradeWalletService; import io.bitsquare.btc.TradeWalletService;
import io.bitsquare.btc.WalletService; import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.BalanceListener; import io.bitsquare.btc.listeners.BalanceListener;
@ -66,6 +67,7 @@ import java.time.Duration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -100,7 +102,7 @@ public class MainViewModel implements ViewModel {
final StringProperty p2PNetworkWarnMsg = new SimpleStringProperty(); final StringProperty p2PNetworkWarnMsg = new SimpleStringProperty();
final StringProperty p2PNetworkIconId = new SimpleStringProperty(); final StringProperty p2PNetworkIconId = new SimpleStringProperty();
final BooleanProperty bootstrapComplete = new SimpleBooleanProperty(); final BooleanProperty bootstrapComplete = new SimpleBooleanProperty();
// software update // software update
final String version = "v." + Version.VERSION; 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 " + "3. The user confirms that he has read and agreed to the rules defined in our " +
"Wiki regrading the dispute process\n" + "Wiki regrading the dispute process\n" +
"(https://github.com/bitsquare/bitsquare/wiki/Arbitration-system)."; "(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") new Popup().headLine("USER AGREEMENT")
.message(text) .message(text)
.actionButtonText("I agree") .actionButtonText("I agree")
.closeButtonText("I disagree and quit") .closeButtonText("I disagree and quit")
.onAction(() -> preferences.setTacAccepted(true)) .onAction(() -> {
.onClose(() -> BitsquareApp.shutDownHandler.run()) 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(); .show();
}
// update nr of peers in footer // update nr of peers in footer
numConnectedPeersListener = (observable, oldValue, newValue) -> { numConnectedPeersListener = (observable, oldValue, newValue) -> {

View file

@ -20,7 +20,6 @@ package io.bitsquare.gui.main.settings.network;
import io.bitsquare.app.BitsquareApp; import io.bitsquare.app.BitsquareApp;
import io.bitsquare.btc.BitcoinNetwork; import io.bitsquare.btc.BitcoinNetwork;
import io.bitsquare.btc.WalletService; import io.bitsquare.btc.WalletService;
import io.bitsquare.common.UserThread;
import io.bitsquare.gui.common.model.Activatable; import io.bitsquare.gui.common.model.Activatable;
import io.bitsquare.gui.common.view.ActivatableViewAndModel; import io.bitsquare.gui.common.view.ActivatableViewAndModel;
import io.bitsquare.gui.common.view.FxmlView; import io.bitsquare.gui.common.view.FxmlView;
@ -193,22 +192,8 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
} }
private void onSelectNetwork() { private void onSelectNetwork() {
if (netWorkComboBox.getSelectionModel().getSelectedItem() != preferences.getBitcoinNetwork()) { if (netWorkComboBox.getSelectionModel().getSelectedItem() != preferences.getBitcoinNetwork())
if (netWorkComboBox.getSelectionModel().getSelectedItem() == BitcoinNetwork.MAINNET) { selectNetwork();
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();
}
}
} }
private void selectNetwork() { private void selectNetwork() {

View file

@ -329,7 +329,7 @@ public class Popup {
closeHandlerOptional.ifPresent(closeHandler -> closeHandler.run()); closeHandlerOptional.ifPresent(closeHandler -> closeHandler.run());
}); });
if (actionHandlerOptional.isPresent()) { if (actionHandlerOptional.isPresent() || actionButtonText != null) {
actionButton = new Button(actionButtonText == null ? "Ok" : actionButtonText); actionButton = new Button(actionButtonText == null ? "Ok" : actionButtonText);
actionButton.setDefaultButton(true); actionButton.setDefaultButton(true);
actionButton.requestFocus(); actionButton.requestFocus();

View file

@ -54,6 +54,6 @@ public class NodeAddress implements Serializable {
@Override @Override
public String toString() { public String toString() {
return getFullAddress(); return getFullAddress() + "\n";
} }
} }

View file

@ -476,7 +476,7 @@ public class Connection implements MessageListener {
shutDownReason = ConnectionListener.Reason.RESET; shutDownReason = ConnectionListener.Reason.RESET;
} else if (e instanceof SocketTimeoutException || e instanceof TimeoutException) { } else if (e instanceof SocketTimeoutException || e instanceof TimeoutException) {
shutDownReason = ConnectionListener.Reason.TIMEOUT; shutDownReason = ConnectionListener.Reason.TIMEOUT;
log.warn("TimeoutException at socket " + socket.toString()); log.debug("TimeoutException at socket " + socket.toString());
log.debug("connection={}" + this); log.debug("connection={}" + this);
} else if (e instanceof EOFException) { } else if (e instanceof EOFException) {
shutDownReason = ConnectionListener.Reason.PEER_DISCONNECTED; shutDownReason = ConnectionListener.Reason.PEER_DISCONNECTED;

View file

@ -75,7 +75,7 @@ public class PeerExchangeHandshake implements MessageListener {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
public void requestReportedPeers(NodeAddress nodeAddress, List<NodeAddress> remainingNodeAddresses) { 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"); checkNotNull(networkNode.getNodeAddress(), "My node address must not be null at requestReportedPeers");
checkArgument(timeoutTimer == null, "requestData must not be called twice."); checkArgument(timeoutTimer == null, "requestData must not be called twice.");

View file

@ -65,7 +65,7 @@ public class PeerExchangeManager implements MessageListener, ConnectionListener
remainingNodeAddresses.remove(nodeAddress); remainingNodeAddresses.remove(nodeAddress);
requestReportedPeers(nodeAddress, remainingNodeAddresses); 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), executor.scheduleAtFixedRate(() -> UserThread.execute(this::maintainConnections),
delay, delay, TimeUnit.SECONDS); delay, delay, TimeUnit.SECONDS);
} }
@ -127,7 +127,7 @@ public class PeerExchangeManager implements MessageListener, ConnectionListener
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
private void requestReportedPeers(NodeAddress nodeAddress, List<NodeAddress> remainingNodeAddresses) { private void requestReportedPeers(NodeAddress nodeAddress, List<NodeAddress> remainingNodeAddresses) {
Log.traceCall("nodeAddress=" + nodeAddress + " / remainingNodeAddresses=" + remainingNodeAddresses); Log.traceCall("nodeAddress=" + nodeAddress);
if (!peerExchangeHandshakeMap.containsKey(nodeAddress)) { if (!peerExchangeHandshakeMap.containsKey(nodeAddress)) {
PeerExchangeHandshake peerExchangeHandshake = new PeerExchangeHandshake(networkNode, PeerExchangeHandshake peerExchangeHandshake = new PeerExchangeHandshake(networkNode,
peerManager, peerManager,
@ -192,17 +192,16 @@ public class PeerExchangeManager implements MessageListener, ConnectionListener
connectToMorePeers(); 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 // Inbound connections should be maintained be the requesting peer
confirmedConnections.stream() confirmedConnections.stream()
.filter(c -> c.getPeersNodeAddressOptional().isPresent() && .filter(c -> c.getPeersNodeAddressOptional().isPresent() &&
c instanceof OutboundConnection && 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(() -> { .forEach(c -> UserThread.runAfterRandomDelay(() -> {
log.trace("Call requestReportedPeers from maintainConnections"); log.trace("Call requestReportedPeers from maintainConnections");
requestReportedPeers(c.getPeersNodeAddressOptional().get(), new ArrayList<>()); requestReportedPeers(c.getPeersNodeAddressOptional().get(), new ArrayList<>());
} }, 3, 5));
, 3, 5));
} }
private void connectToMorePeers() { private void connectToMorePeers() {

View file

@ -83,8 +83,7 @@ public class PeerManager implements ConnectionListener, MessageListener {
if (dbStorage != null) { if (dbStorage != null) {
HashSet<ReportedPeer> persistedPeers = dbStorage.initAndGetPersisted("persistedPeers"); HashSet<ReportedPeer> persistedPeers = dbStorage.initAndGetPersisted("persistedPeers");
if (persistedPeers != null) { if (persistedPeers != null) {
log.info("We have persisted reported peers. " + log.info("We have persisted reported peers. persistedPeers.size()=" + persistedPeers.size());
"\npersistedPeers=" + persistedPeers);
this.persistedPeers.addAll(persistedPeers); this.persistedPeers.addAll(persistedPeers);
} }
} }
@ -237,7 +236,7 @@ public class PeerManager implements ConnectionListener, MessageListener {
} }
public void addToReportedPeers(HashSet<ReportedPeer> reportedPeersToAdd, Connection connection) { public void addToReportedPeers(HashSet<ReportedPeer> reportedPeersToAdd, Connection connection) {
Log.traceCall("reportedPeersToAdd = " + reportedPeersToAdd); Log.traceCall();
// we disconnect misbehaving nodes trying to send too many peers // 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 // reported peers include the connected peers which is normally max. 10 but we give some headroom
// for safety // for safety

View file

@ -31,7 +31,7 @@ public final class GetPeersRequest extends PeerExchangeMessage implements Sender
return "GetPeersRequest{" + return "GetPeersRequest{" +
"senderNodeAddress=" + senderNodeAddress + "senderNodeAddress=" + senderNodeAddress +
", requestNonce=" + nonce + ", requestNonce=" + nonce +
", reportedPeers=" + reportedPeers + ", reportedPeers.size()=" + reportedPeers.size() +
super.toString() + "} "; super.toString() + "} ";
} }

View file

@ -21,7 +21,7 @@ public final class GetPeersResponse extends PeerExchangeMessage {
public String toString() { public String toString() {
return "GetPeersResponse{" + return "GetPeersResponse{" +
"requestNonce=" + requestNonce + "requestNonce=" + requestNonce +
", reportedPeers=" + reportedPeers + ", reportedPeers.size()=" + reportedPeers.size() +
super.toString() + "} "; super.toString() + "} ";
} }
} }