Refactor bootstrap node definitions

This commit is contained in:
Manfred Karrer 2015-05-17 14:56:05 +02:00
parent 68a4178bf3
commit 19bb552224
14 changed files with 214 additions and 138 deletions

View file

@ -117,7 +117,7 @@ public class BitsquareAppMain extends BitsquareExecutable {
.ofType(boolean.class);
parser.accepts(NAME_KEY, description("Name of this node", null))
.withRequiredArg();
parser.accepts(PORT_KEY, description("Port to listen on", Node.DEFAULT_PORT))
parser.accepts(PORT_KEY, description("Port to listen on", Node.CLIENT_PORT))
.withRequiredArg()
.ofType(int.class);
parser.accepts(USE_MANUAL_PORT_FORWARDING_KEY, description("Use manual port forwarding", false))
@ -134,11 +134,14 @@ public class BitsquareAppMain extends BitsquareExecutable {
.withValuesConvertedBy(new EnumValueConverter(RegTestHost.class));
parser.accepts(BOOTSTRAP_NODE_NAME_KEY, description("", BootstrapNodes.getSelectedNode().getName()))
parser.accepts(BOOTSTRAP_NODE_NAME_KEY, description("Bootstrap node name", BootstrapNodes.getLocalhostNode().getName()))
.withRequiredArg();
parser.accepts(BOOTSTRAP_NODE_IP_KEY, description("", BootstrapNodes.getSelectedNode().getIp()))
parser.accepts(BOOTSTRAP_NODE_IP_KEY, description("Bootstrap node IP", BootstrapNodes.getLocalhostNode().getIp()))
.withRequiredArg();
parser.accepts(BOOTSTRAP_NODE_PORT_KEY, description("", BootstrapNodes.getSelectedNode().getPort()))
parser.accepts(BOOTSTRAP_NODE_P2P_ID_KEY, description("Bootstrap node p2p network ID", BootstrapNodes.getLocalhostNode().getPort()))
.withRequiredArg()
.ofType(int.class);
parser.accepts(BOOTSTRAP_NODE_PORT_KEY, description("Bootstrap node port", BootstrapNodes.getLocalhostNode().getPort()))
.withRequiredArg()
.ofType(int.class);
parser.accepts(NETWORK_INTERFACE_KEY, description("Network interface", null))

View file

@ -77,7 +77,7 @@ class MainViewModel implements ViewModel {
private final OpenOfferManager openOfferManager;
private final UpdateProcess updateProcess;
private final BSFormatter formatter;
private final int networkId;
private final int p2pId;
// BTC network
final StringProperty blockchainSyncInfo = new SimpleStringProperty("Initializing");
@ -132,7 +132,7 @@ class MainViewModel implements ViewModel {
this.formatter = formatter;
bitcoinNetworkAsString = formatter.formatBitcoinNetwork(preferences.getBitcoinNetwork());
networkId = preferences.getBitcoinNetwork().ordinal();
p2pId = preferences.getBitcoinNetwork().ordinal() + 10; // p2pId: Mainnet 10, testnet 11, regtest 12
updateProcess.state.addListener((observableValue, oldValue, newValue) -> applyUpdateState(newValue));
applyUpdateState(updateProcess.state.get());
@ -206,7 +206,7 @@ class MainViewModel implements ViewModel {
});
clientNode.setExecutor(Platform::runLater);
Observable<BootstrappedPeerBuilder.State> bootstrapStateAsObservable = clientNode.bootstrap(networkId, keyRing.getDhtSignatureKeyPair());
Observable<BootstrappedPeerBuilder.State> bootstrapStateAsObservable = clientNode.bootstrap(p2pId, keyRing.getDhtSignatureKeyPair());
bootstrapStateAsObservable.publish();
bootstrapStateAsObservable.subscribe(
state -> Platform.runLater(() -> setBootstrapState(state)),

View file

@ -71,8 +71,8 @@ public class NetworkSettingsView extends InitializableView {
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());
nodeAddress.setText(clientNode.getClientNodeInfo());
bootstrapNodeAddress.setText(clientNode.getBootstrapNode().toString());
useUPnP.setSelected(preferences.getUseUPnP());