Add new bootstrap node servers

This commit is contained in:
Manfred Karrer 2015-05-10 09:17:09 +02:00
parent 44c8cf9c26
commit c1e0524090
18 changed files with 231 additions and 115 deletions

View file

@ -134,11 +134,11 @@ public class BitsquareAppMain extends BitsquareExecutable {
.withValuesConvertedBy(new EnumValueConverter(RegTestHost.class));
parser.accepts(BOOTSTRAP_NODE_NAME_KEY, description("", BootstrapNodes.DEFAULT.getName()))
parser.accepts(BOOTSTRAP_NODE_NAME_KEY, description("", BootstrapNodes.getSelectedNode().getName()))
.withRequiredArg();
parser.accepts(BOOTSTRAP_NODE_IP_KEY, description("", BootstrapNodes.DEFAULT.getIp()))
parser.accepts(BOOTSTRAP_NODE_IP_KEY, description("", BootstrapNodes.getSelectedNode().getIp()))
.withRequiredArg();
parser.accepts(BOOTSTRAP_NODE_PORT_KEY, description("", BootstrapNodes.DEFAULT.getPort()))
parser.accepts(BOOTSTRAP_NODE_PORT_KEY, description("", BootstrapNodes.getSelectedNode().getPort()))
.withRequiredArg()
.ofType(int.class);
parser.accepts(NETWORK_INTERFACE_KEY, description("Network interface", null))

View file

@ -360,10 +360,15 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
bitcoinNetworkLabel.setText(model.bitcoinNetworkAsString);
model.walletServiceErrorMsg.addListener((ov, oldValue, newValue) -> {
bitcoinNetworkLabel.setId("splash-error-state-msg");
bitcoinNetworkLabel.textProperty().unbind();
bitcoinNetworkLabel.setText("Not connected");
openBTCConnectionErrorPopup(newValue);
if (newValue != null) {
bitcoinNetworkLabel.setId("splash-error-state-msg");
bitcoinNetworkLabel.setText("Not connected");
openBTCConnectionErrorPopup(newValue);
}
else {
bitcoinNetworkLabel.setId("footer-bitcoin-network-label");
bitcoinNetworkLabel.setText(model.bitcoinNetworkAsString);
}
});
model.blockchainSyncProgress.addListener((ov, oldValue, newValue) -> {
@ -412,11 +417,17 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
setBottomAnchor(numPeersLabel, 7d);
numPeersLabel.textProperty().bind(model.numDHTPeers);
model.bootstrapErrorMsg.addListener((ov, oldValue, newValue) -> {
bootstrapLabel.setId("splash-error-state-msg");
bootstrapLabel.textProperty().unbind();
bootstrapLabel.setText("Not connected");
Popups.openErrorPopup("Error", "Connecting to the P2P network failed. \n" + newValue
+ "\nPlease check our internet connection.");
if (newValue != null) {
bootstrapLabel.setId("splash-error-state-msg");
bootstrapLabel.textProperty().unbind();
bootstrapLabel.setText("Not connected");
Popups.openErrorPopup("Error", "Connecting to the P2P network failed. \n" + newValue
+ "\nPlease check your internet connection.");
}
else {
bootstrapLabel.setId("footer-pane");
bootstrapLabel.textProperty().bind(model.bootstrapInfoFooter);
}
});
AnchorPane footerContainer = new AnchorPane(separator, blockchainSyncBox, versionLabel, bootstrapLabel, bootstrapIcon, numPeersLabel) {{
@ -549,6 +560,6 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
private void openBTCConnectionErrorPopup(String errorMsg) {
Popups.openErrorPopup("Error", "Connecting to the bitcoin network failed. \n" + errorMsg
+ "\nPlease check our internet connection.");
+ "\nPlease check your internet connection.");
}
}

View file

@ -36,6 +36,8 @@ import io.bitsquare.trade.offer.OpenOfferManager;
import io.bitsquare.user.User;
import io.bitsquare.util.Utilities;
import org.bitcoinj.store.BlockStoreException;
import com.google.inject.Inject;
import java.util.Timer;
@ -65,6 +67,17 @@ class MainViewModel implements ViewModel {
private static final long BLOCKCHAIN_SYNC_TIMEOUT = 30000;
private static final long LOST_CONNECTION_TIMEOUT = 10000;
private final User user;
private final KeyRing keyRing;
private final WalletService walletService;
private final ArbitrationRepository arbitrationRepository;
private final ClientNode clientNode;
private final TradeManager tradeManager;
private final OpenOfferManager openOfferManager;
private final UpdateProcess updateProcess;
private final BSFormatter formatter;
private final int networkId;
// BTC network
final StringProperty blockchainSyncInfo = new SimpleStringProperty("Initializing");
final StringProperty blockchainSyncInfoFooter = new SimpleStringProperty("Initializing");
@ -98,15 +111,6 @@ class MainViewModel implements ViewModel {
final String bitcoinNetworkAsString;
private final User user;
private KeyRing keyRing;
private final WalletService walletService;
private final ArbitrationRepository arbitrationRepository;
private final ClientNode clientNode;
private final TradeManager tradeManager;
private OpenOfferManager openOfferManager;
private final UpdateProcess updateProcess;
private final BSFormatter formatter;
private Timer blockchainSyncTimeoutTimer;
private Timer lostConnectionTimeoutTimer;
@ -126,6 +130,7 @@ class MainViewModel implements ViewModel {
this.formatter = formatter;
bitcoinNetworkAsString = formatter.formatBitcoinNetwork(bitcoinNetwork);
networkId = bitcoinNetwork.ordinal();
updateProcess.state.addListener((observableValue, oldValue, newValue) -> applyUpdateState(newValue));
applyUpdateState(updateProcess.state.get());
@ -146,7 +151,8 @@ class MainViewModel implements ViewModel {
public void initBackend() {
Platform.runLater(updateProcess::init);
startBlockchainSyncTimeout();
if (walletService.downloadPercentageProperty().get() > -1)
startBlockchainSyncTimeout();
walletService.downloadPercentageProperty().addListener((ov, oldValue, newValue) -> {
setBitcoinNetworkSyncProgress((double) newValue);
@ -155,9 +161,10 @@ class MainViewModel implements ViewModel {
walletService.numPeersProperty().addListener((observable, oldValue, newValue) -> {
numBTCPeers.set(String.valueOf(newValue) + " peers");
if ((int) newValue < 1) {
if ((int) newValue < 1)
walletServiceErrorMsg.set("We lost connection to the last peer.");
}
else
walletServiceErrorMsg.set(null);
});
// Set executor for all P2PServices
@ -178,10 +185,12 @@ class MainViewModel implements ViewModel {
lostConnectionTimeoutTimer.cancel();
lostConnectionTimeoutTimer = null;
}
bootstrapErrorMsg.set(null);
}
});
Observable<BootstrappedPeerBuilder.State> bootstrapStateAsObservable = clientNode.bootstrap(keyRing.getDhtSignatureKeyPair());
clientNode.setExecutor(Platform::runLater);
Observable<BootstrappedPeerBuilder.State> bootstrapStateAsObservable = clientNode.bootstrap(networkId, keyRing.getDhtSignatureKeyPair());
bootstrapStateAsObservable.publish();
bootstrapStateAsObservable.subscribe(
state -> Platform.runLater(() -> setBootstrapState(state)),
@ -229,6 +238,7 @@ class MainViewModel implements ViewModel {
private void onAllServicesInitialized() {
log.trace("backend completed");
setBitcoinNetworkSyncProgress(walletService.downloadPercentageProperty().get());
tradeManager.getPendingTrades().addListener((ListChangeListener<Trade>) change -> updateNumPendingTrades());
updateNumPendingTrades();
showAppScreen.set(true);
@ -321,6 +331,9 @@ class MainViewModel implements ViewModel {
"You must allow outgoing TCP connections to port 18333 for the bitcoin testnet.\n\n" +
"See https://github.com/bitsquare/bitsquare/wiki for instructions.");
}
else if (error.getCause() instanceof BlockStoreException) {
walletServiceErrorMsg.set("You cannot run 2 instances of the program.");
}
else if (error.getMessage() != null) {
walletServiceErrorMsg.set(error.getMessage());
}
@ -365,6 +378,8 @@ class MainViewModel implements ViewModel {
private void setBitcoinNetworkSyncProgress(double value) {
blockchainSyncProgress.set(value);
if (value >= 1) {
stopBlockchainSyncTimeout();
blockchainSyncInfo.set("Blockchain synchronization complete.");
blockchainSyncIconId.set("image-connection-synced");
}

View file

@ -45,20 +45,29 @@
</GridPane.margin>
</TextField>
<Label text="P2P network connection:" GridPane.rowIndex="1"/>
<TextField fx:id="connectionType" GridPane.rowIndex="1" GridPane.columnIndex="1"
<Label text="Bitcoin network connected peers:" GridPane.rowIndex="1"/>
<TextField fx:id="connectedPeersBTC" GridPane.rowIndex="1" GridPane.columnIndex="1"
mouseTransparent="true" focusTraversable="false"/>
<Label text="My external visible P2P network address:" GridPane.rowIndex="2"/>
<TextField fx:id="nodeAddress" GridPane.rowIndex="2" GridPane.columnIndex="1"
<Label text="P2P network connection:" GridPane.rowIndex="2"/>
<TextField fx:id="connectionType" GridPane.rowIndex="2" GridPane.columnIndex="1"
mouseTransparent="true" focusTraversable="false"/>
<Label text="P2P bootstrap node address:" GridPane.rowIndex="3">
<Label text="P2P network connected peers:" GridPane.rowIndex="3"/>
<TextField fx:id="connectedPeersP2P" GridPane.rowIndex="3" GridPane.columnIndex="1"
mouseTransparent="true" focusTraversable="false"/>
<Label text="My external visible P2P network address:" GridPane.rowIndex="4"/>
<TextField fx:id="nodeAddress" GridPane.rowIndex="4" GridPane.columnIndex="1"
mouseTransparent="true" focusTraversable="false"/>
<Label text="P2P bootstrap node address:" GridPane.rowIndex="5">
<GridPane.margin>
<Insets bottom="-15"/>
</GridPane.margin>
</Label>
<TextField fx:id="bootstrapNodeAddress" GridPane.rowIndex="3" GridPane.columnIndex="1"
<TextField fx:id="bootstrapNodeAddress" GridPane.rowIndex="5" GridPane.columnIndex="1"
mouseTransparent="true" focusTraversable="false">
<GridPane.margin>
<Insets bottom="-15"/>

View file

@ -18,6 +18,7 @@
package io.bitsquare.gui.main.settings.network;
import io.bitsquare.btc.BitcoinNetwork;
import io.bitsquare.btc.WalletService;
import io.bitsquare.gui.common.view.FxmlView;
import io.bitsquare.gui.common.view.InitializableView;
import io.bitsquare.gui.util.BSFormatter;
@ -28,23 +29,31 @@ import javax.inject.Inject;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import static javafx.beans.binding.Bindings.createStringBinding;
@FxmlView
public class NetworkSettingsView extends InitializableView {
private final String bitcoinNetworkString;
private final WalletService walletService;
private final ClientNode clientNode;
@FXML TextField bitcoinNetwork, connectionType, nodeAddress, bootstrapNodeAddress;
@FXML TextField bitcoinNetwork, connectionType, nodeAddress, bootstrapNodeAddress, connectedPeersBTC, connectedPeersP2P;
@Inject
public NetworkSettingsView(BitcoinNetwork bitcoinNetwork, ClientNode clientNode, BSFormatter formatter) {
public NetworkSettingsView(BitcoinNetwork bitcoinNetwork, WalletService walletService, ClientNode clientNode, BSFormatter formatter) {
this.walletService = walletService;
this.bitcoinNetworkString = formatter.formatBitcoinNetwork(bitcoinNetwork);
this.clientNode = clientNode;
}
public void initialize() {
bitcoinNetwork.setText(bitcoinNetworkString);
connectedPeersBTC.textProperty().bind(createStringBinding(() -> String.valueOf(walletService.numPeersProperty().get()), walletService
.numPeersProperty()));
connectionType.setText(clientNode.getConnectionType().toString());
connectedPeersP2P.textProperty().bind(createStringBinding(() -> String.valueOf(clientNode.numPeersProperty().get()), clientNode.numPeersProperty()));
nodeAddress.setText(clientNode.getAddress().toString());
bootstrapNodeAddress.setText(clientNode.getBootstrapNodeAddress().toString());
}