mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-09-19 20:44:36 -04:00
Revert "Rename BootstrappedPeerFactory to BootstrappedPeerDHTBuilder"
This reverts commit 00455dfd7a
.
This commit is contained in:
parent
00455dfd7a
commit
14cdc3e4c2
4 changed files with 21 additions and 21 deletions
|
@ -19,7 +19,7 @@ package io.bitsquare.gui.main.preferences.network;
|
||||||
|
|
||||||
import io.bitsquare.BitsquareException;
|
import io.bitsquare.BitsquareException;
|
||||||
import io.bitsquare.gui.PresentationModel;
|
import io.bitsquare.gui.PresentationModel;
|
||||||
import io.bitsquare.msg.tomp2p.BootstrappedPeerDHTBuilder;
|
import io.bitsquare.msg.tomp2p.BootstrappedPeerFactory;
|
||||||
import io.bitsquare.msg.tomp2p.TomP2PNode;
|
import io.bitsquare.msg.tomp2p.TomP2PNode;
|
||||||
import io.bitsquare.network.BootstrapState;
|
import io.bitsquare.network.BootstrapState;
|
||||||
import io.bitsquare.network.Node;
|
import io.bitsquare.network.Node;
|
||||||
|
@ -49,9 +49,9 @@ public class NetworkPreferencesPM extends PresentationModel {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
NetworkPreferencesPM(NetworkParameters networkParameters,
|
NetworkPreferencesPM(NetworkParameters networkParameters,
|
||||||
BootstrappedPeerDHTBuilder bootstrappedPeerDHTBuilder,
|
BootstrappedPeerFactory bootstrappedPeerFactory,
|
||||||
TomP2PNode tomP2PNode,
|
TomP2PNode tomP2PNode,
|
||||||
@Named(BootstrappedPeerDHTBuilder.BOOTSTRAP_NODE_KEY) Node bootstrapNode) {
|
@Named(BootstrappedPeerFactory.BOOTSTRAP_NODE_KEY) Node bootstrapNode) {
|
||||||
|
|
||||||
switch (networkParameters.getId()) {
|
switch (networkParameters.getId()) {
|
||||||
case NetworkParameters.ID_REGTEST:
|
case NetworkParameters.ID_REGTEST:
|
||||||
|
@ -77,7 +77,7 @@ public class NetworkPreferencesPM extends PresentationModel {
|
||||||
+ ", IP: " + bootstrapNode.getIp()
|
+ ", IP: " + bootstrapNode.getIp()
|
||||||
+ ", Port: " + bootstrapNode.getPortAsString();
|
+ ", Port: " + bootstrapNode.getPortAsString();
|
||||||
|
|
||||||
BootstrapState state = bootstrappedPeerDHTBuilder.bootstrapState.get();
|
BootstrapState state = bootstrappedPeerFactory.bootstrapState.get();
|
||||||
if (state == BootstrapState.DIRECT_SUCCESS)
|
if (state == BootstrapState.DIRECT_SUCCESS)
|
||||||
p2pNetworkConnection = "Direct connection";
|
p2pNetworkConnection = "Direct connection";
|
||||||
else if (state == BootstrapState.NAT_SUCCESS)
|
else if (state == BootstrapState.NAT_SUCCESS)
|
||||||
|
|
|
@ -70,8 +70,8 @@ import org.slf4j.LoggerFactory;
|
||||||
/**
|
/**
|
||||||
* Creates a DHT peer and bootstraps to the network via a bootstrap node
|
* Creates a DHT peer and bootstraps to the network via a bootstrap node
|
||||||
*/
|
*/
|
||||||
public class BootstrappedPeerDHTBuilder {
|
public class BootstrappedPeerFactory {
|
||||||
private static final Logger log = LoggerFactory.getLogger(BootstrappedPeerDHTBuilder.class);
|
private static final Logger log = LoggerFactory.getLogger(BootstrappedPeerFactory.class);
|
||||||
|
|
||||||
public static final String BOOTSTRAP_NODE_KEY = "bootstrapNode";
|
public static final String BOOTSTRAP_NODE_KEY = "bootstrapNode";
|
||||||
static final String NETWORK_INTERFACE_KEY = "interface";
|
static final String NETWORK_INTERFACE_KEY = "interface";
|
||||||
|
@ -94,10 +94,10 @@ public class BootstrappedPeerDHTBuilder {
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BootstrappedPeerDHTBuilder(Persistence persistence,
|
public BootstrappedPeerFactory(Persistence persistence,
|
||||||
@Named(Node.PORT_KEY) int port,
|
@Named(Node.PORT_KEY) int port,
|
||||||
@Named(BOOTSTRAP_NODE_KEY) Node bootstrapNode,
|
@Named(BOOTSTRAP_NODE_KEY) Node bootstrapNode,
|
||||||
@Named(NETWORK_INTERFACE_KEY) String networkInterface) {
|
@Named(NETWORK_INTERFACE_KEY) String networkInterface) {
|
||||||
this.persistence = persistence;
|
this.persistence = persistence;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.bootstrapNode = bootstrapNode;
|
this.bootstrapNode = bootstrapNode;
|
||||||
|
@ -314,7 +314,7 @@ public class BootstrappedPeerDHTBuilder {
|
||||||
public void operationComplete(BaseFuture future) throws Exception {
|
public void operationComplete(BaseFuture future) throws Exception {
|
||||||
if (futureBootstrap.isSuccess()) {
|
if (futureBootstrap.isSuccess()) {
|
||||||
setState(state, "Bootstrap successful.");
|
setState(state, "Bootstrap successful.");
|
||||||
persistence.write(BootstrappedPeerDHTBuilder.this, "lastSuccessfulBootstrap", state);
|
persistence.write(BootstrappedPeerFactory.this, "lastSuccessfulBootstrap", state);
|
||||||
settableFuture.set(peerDHT);
|
settableFuture.set(peerDHT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
|
@ -26,14 +26,14 @@ import com.google.inject.name.Names;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
|
||||||
import static io.bitsquare.msg.tomp2p.BootstrappedPeerDHTBuilder.*;
|
import static io.bitsquare.msg.tomp2p.BootstrappedPeerFactory.*;
|
||||||
|
|
||||||
public class TomP2PMessageModule extends MessageModule {
|
public class TomP2PMessageModule extends MessageModule {
|
||||||
|
|
||||||
public static final String BOOTSTRAP_NODE_NAME_KEY = "bootstrap.node.name";
|
public static final String BOOTSTRAP_NODE_NAME_KEY = "bootstrap.node.name";
|
||||||
public static final String BOOTSTRAP_NODE_IP_KEY = "bootstrap.node.ip";
|
public static final String BOOTSTRAP_NODE_IP_KEY = "bootstrap.node.ip";
|
||||||
public static final String BOOTSTRAP_NODE_PORT_KEY = "bootstrap.node.port";
|
public static final String BOOTSTRAP_NODE_PORT_KEY = "bootstrap.node.port";
|
||||||
public static final String NETWORK_INTERFACE_KEY = BootstrappedPeerDHTBuilder.NETWORK_INTERFACE_KEY;
|
public static final String NETWORK_INTERFACE_KEY = BootstrappedPeerFactory.NETWORK_INTERFACE_KEY;
|
||||||
|
|
||||||
public TomP2PMessageModule(Environment env) {
|
public TomP2PMessageModule(Environment env) {
|
||||||
super(env);
|
super(env);
|
||||||
|
@ -54,7 +54,7 @@ public class TomP2PMessageModule extends MessageModule {
|
||||||
);
|
);
|
||||||
bindConstant().annotatedWith(Names.named(NETWORK_INTERFACE_KEY)).to(
|
bindConstant().annotatedWith(Names.named(NETWORK_INTERFACE_KEY)).to(
|
||||||
env.getProperty(NETWORK_INTERFACE_KEY, NETWORK_INTERFACE_UNSPECIFIED));
|
env.getProperty(NETWORK_INTERFACE_KEY, NETWORK_INTERFACE_UNSPECIFIED));
|
||||||
bind(BootstrappedPeerDHTBuilder.class).asEagerSingleton();
|
bind(BootstrappedPeerFactory.class).asEagerSingleton();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class TomP2PNode {
|
||||||
private PeerAddress storedPeerAddress;
|
private PeerAddress storedPeerAddress;
|
||||||
|
|
||||||
private PeerDHT peerDHT;
|
private PeerDHT peerDHT;
|
||||||
private BootstrappedPeerDHTBuilder bootstrappedPeerDHTBuilder;
|
private BootstrappedPeerFactory bootstrappedPeerFactory;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -84,8 +84,8 @@ public class TomP2PNode {
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TomP2PNode(BootstrappedPeerDHTBuilder bootstrappedPeerDHTBuilder) {
|
public TomP2PNode(BootstrappedPeerFactory bootstrappedPeerFactory) {
|
||||||
this.bootstrappedPeerDHTBuilder = bootstrappedPeerDHTBuilder;
|
this.bootstrappedPeerFactory = bootstrappedPeerFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for unit testing
|
// for unit testing
|
||||||
|
@ -108,17 +108,17 @@ public class TomP2PNode {
|
||||||
|
|
||||||
public void setKeyPair(@NotNull KeyPair keyPair) {
|
public void setKeyPair(@NotNull KeyPair keyPair) {
|
||||||
this.keyPair = keyPair;
|
this.keyPair = keyPair;
|
||||||
bootstrappedPeerDHTBuilder.setKeyPair(keyPair);
|
bootstrappedPeerFactory.setKeyPair(keyPair);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bootstrap(BootstrapListener bootstrapListener) {
|
public void bootstrap(BootstrapListener bootstrapListener) {
|
||||||
checkNotNull(keyPair, "keyPair must not be null.");
|
checkNotNull(keyPair, "keyPair must not be null.");
|
||||||
checkNotNull(messageBroker, "messageBroker must not be null.");
|
checkNotNull(messageBroker, "messageBroker must not be null.");
|
||||||
|
|
||||||
bootstrappedPeerDHTBuilder.bootstrapState.addListener((ov, oldValue, newValue) ->
|
bootstrappedPeerFactory.bootstrapState.addListener((ov, oldValue, newValue) ->
|
||||||
bootstrapListener.onBootstrapStateChanged(newValue));
|
bootstrapListener.onBootstrapStateChanged(newValue));
|
||||||
|
|
||||||
SettableFuture<PeerDHT> bootstrapFuture = bootstrappedPeerDHTBuilder.start();
|
SettableFuture<PeerDHT> bootstrapFuture = bootstrappedPeerFactory.start();
|
||||||
Futures.addCallback(bootstrapFuture, new FutureCallback<PeerDHT>() {
|
Futures.addCallback(bootstrapFuture, new FutureCallback<PeerDHT>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(@Nullable PeerDHT peerDHT) {
|
public void onSuccess(@Nullable PeerDHT peerDHT) {
|
||||||
|
@ -149,7 +149,7 @@ public class TomP2PNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutDown() {
|
public void shutDown() {
|
||||||
bootstrappedPeerDHTBuilder.shutDown();
|
bootstrappedPeerFactory.shutDown();
|
||||||
|
|
||||||
if (peerDHT != null)
|
if (peerDHT != null)
|
||||||
peerDHT.shutdown();
|
peerDHT.shutdown();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue