mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 07:15:54 -04:00
Revert "Rename BootstrappedPeerFactory to BootstrappedPeerDHTBuilder"
This reverts commit 00455dfd7ac1119180412923ff9be7ea31617acb.
This commit is contained in:
parent
00455dfd7a
commit
14cdc3e4c2
@ -19,7 +19,7 @@ package io.bitsquare.gui.main.preferences.network;
|
||||
|
||||
import io.bitsquare.BitsquareException;
|
||||
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.network.BootstrapState;
|
||||
import io.bitsquare.network.Node;
|
||||
@ -49,9 +49,9 @@ public class NetworkPreferencesPM extends PresentationModel {
|
||||
|
||||
@Inject
|
||||
NetworkPreferencesPM(NetworkParameters networkParameters,
|
||||
BootstrappedPeerDHTBuilder bootstrappedPeerDHTBuilder,
|
||||
BootstrappedPeerFactory bootstrappedPeerFactory,
|
||||
TomP2PNode tomP2PNode,
|
||||
@Named(BootstrappedPeerDHTBuilder.BOOTSTRAP_NODE_KEY) Node bootstrapNode) {
|
||||
@Named(BootstrappedPeerFactory.BOOTSTRAP_NODE_KEY) Node bootstrapNode) {
|
||||
|
||||
switch (networkParameters.getId()) {
|
||||
case NetworkParameters.ID_REGTEST:
|
||||
@ -77,7 +77,7 @@ public class NetworkPreferencesPM extends PresentationModel {
|
||||
+ ", IP: " + bootstrapNode.getIp()
|
||||
+ ", Port: " + bootstrapNode.getPortAsString();
|
||||
|
||||
BootstrapState state = bootstrappedPeerDHTBuilder.bootstrapState.get();
|
||||
BootstrapState state = bootstrappedPeerFactory.bootstrapState.get();
|
||||
if (state == BootstrapState.DIRECT_SUCCESS)
|
||||
p2pNetworkConnection = "Direct connection";
|
||||
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
|
||||
*/
|
||||
public class BootstrappedPeerDHTBuilder {
|
||||
private static final Logger log = LoggerFactory.getLogger(BootstrappedPeerDHTBuilder.class);
|
||||
public class BootstrappedPeerFactory {
|
||||
private static final Logger log = LoggerFactory.getLogger(BootstrappedPeerFactory.class);
|
||||
|
||||
public static final String BOOTSTRAP_NODE_KEY = "bootstrapNode";
|
||||
static final String NETWORK_INTERFACE_KEY = "interface";
|
||||
@ -94,10 +94,10 @@ public class BootstrappedPeerDHTBuilder {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public BootstrappedPeerDHTBuilder(Persistence persistence,
|
||||
@Named(Node.PORT_KEY) int port,
|
||||
@Named(BOOTSTRAP_NODE_KEY) Node bootstrapNode,
|
||||
@Named(NETWORK_INTERFACE_KEY) String networkInterface) {
|
||||
public BootstrappedPeerFactory(Persistence persistence,
|
||||
@Named(Node.PORT_KEY) int port,
|
||||
@Named(BOOTSTRAP_NODE_KEY) Node bootstrapNode,
|
||||
@Named(NETWORK_INTERFACE_KEY) String networkInterface) {
|
||||
this.persistence = persistence;
|
||||
this.port = port;
|
||||
this.bootstrapNode = bootstrapNode;
|
||||
@ -314,7 +314,7 @@ public class BootstrappedPeerDHTBuilder {
|
||||
public void operationComplete(BaseFuture future) throws Exception {
|
||||
if (futureBootstrap.isSuccess()) {
|
||||
setState(state, "Bootstrap successful.");
|
||||
persistence.write(BootstrappedPeerDHTBuilder.this, "lastSuccessfulBootstrap", state);
|
||||
persistence.write(BootstrappedPeerFactory.this, "lastSuccessfulBootstrap", state);
|
||||
settableFuture.set(peerDHT);
|
||||
}
|
||||
else {
|
@ -26,14 +26,14 @@ import com.google.inject.name.Names;
|
||||
|
||||
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 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_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) {
|
||||
super(env);
|
||||
@ -54,7 +54,7 @@ public class TomP2PMessageModule extends MessageModule {
|
||||
);
|
||||
bindConstant().annotatedWith(Names.named(NETWORK_INTERFACE_KEY)).to(
|
||||
env.getProperty(NETWORK_INTERFACE_KEY, NETWORK_INTERFACE_UNSPECIFIED));
|
||||
bind(BootstrappedPeerDHTBuilder.class).asEagerSingleton();
|
||||
bind(BootstrappedPeerFactory.class).asEagerSingleton();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,7 +76,7 @@ public class TomP2PNode {
|
||||
private PeerAddress storedPeerAddress;
|
||||
|
||||
private PeerDHT peerDHT;
|
||||
private BootstrappedPeerDHTBuilder bootstrappedPeerDHTBuilder;
|
||||
private BootstrappedPeerFactory bootstrappedPeerFactory;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -84,8 +84,8 @@ public class TomP2PNode {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public TomP2PNode(BootstrappedPeerDHTBuilder bootstrappedPeerDHTBuilder) {
|
||||
this.bootstrappedPeerDHTBuilder = bootstrappedPeerDHTBuilder;
|
||||
public TomP2PNode(BootstrappedPeerFactory bootstrappedPeerFactory) {
|
||||
this.bootstrappedPeerFactory = bootstrappedPeerFactory;
|
||||
}
|
||||
|
||||
// for unit testing
|
||||
@ -108,17 +108,17 @@ public class TomP2PNode {
|
||||
|
||||
public void setKeyPair(@NotNull KeyPair keyPair) {
|
||||
this.keyPair = keyPair;
|
||||
bootstrappedPeerDHTBuilder.setKeyPair(keyPair);
|
||||
bootstrappedPeerFactory.setKeyPair(keyPair);
|
||||
}
|
||||
|
||||
public void bootstrap(BootstrapListener bootstrapListener) {
|
||||
checkNotNull(keyPair, "keyPair 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));
|
||||
|
||||
SettableFuture<PeerDHT> bootstrapFuture = bootstrappedPeerDHTBuilder.start();
|
||||
SettableFuture<PeerDHT> bootstrapFuture = bootstrappedPeerFactory.start();
|
||||
Futures.addCallback(bootstrapFuture, new FutureCallback<PeerDHT>() {
|
||||
@Override
|
||||
public void onSuccess(@Nullable PeerDHT peerDHT) {
|
||||
@ -149,7 +149,7 @@ public class TomP2PNode {
|
||||
}
|
||||
|
||||
public void shutDown() {
|
||||
bootstrappedPeerDHTBuilder.shutDown();
|
||||
bootstrappedPeerFactory.shutDown();
|
||||
|
||||
if (peerDHT != null)
|
||||
peerDHT.shutdown();
|
||||
|
Loading…
x
Reference in New Issue
Block a user