mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-12-16 00:04:09 -05:00
Renamed NetworkModule to P2PModule
This commit is contained in:
parent
5b090cf7b8
commit
79698df651
9 changed files with 38 additions and 48 deletions
|
|
@ -26,7 +26,6 @@ import io.bitsquare.gui.components.Popups;
|
||||||
import io.bitsquare.gui.main.MainView;
|
import io.bitsquare.gui.main.MainView;
|
||||||
import io.bitsquare.gui.main.debug.DebugView;
|
import io.bitsquare.gui.main.debug.DebugView;
|
||||||
import io.bitsquare.gui.util.ImageUtil;
|
import io.bitsquare.gui.util.ImageUtil;
|
||||||
import io.bitsquare.p2p.tomp2p.TomP2PService;
|
|
||||||
import io.bitsquare.persistence.Persistence;
|
import io.bitsquare.persistence.Persistence;
|
||||||
import io.bitsquare.user.AccountSettings;
|
import io.bitsquare.user.AccountSettings;
|
||||||
import io.bitsquare.user.User;
|
import io.bitsquare.user.User;
|
||||||
|
|
@ -40,7 +39,6 @@ import com.google.inject.Injector;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.application.Platform;
|
|
||||||
import javafx.scene.*;
|
import javafx.scene.*;
|
||||||
import javafx.scene.image.*;
|
import javafx.scene.image.*;
|
||||||
import javafx.scene.input.*;
|
import javafx.scene.input.*;
|
||||||
|
|
@ -74,7 +72,6 @@ public class BitsquareApp extends Application {
|
||||||
this.primaryStage = primaryStage;
|
this.primaryStage = primaryStage;
|
||||||
|
|
||||||
log.trace("BitsquareApp.start");
|
log.trace("BitsquareApp.start");
|
||||||
TomP2PService.setUserThread(Platform::runLater);
|
|
||||||
|
|
||||||
bitsquareAppModule = new BitsquareAppModule(env, primaryStage);
|
bitsquareAppModule = new BitsquareAppModule(env, primaryStage);
|
||||||
injector = Guice.createInjector(bitsquareAppModule);
|
injector = Guice.createInjector(bitsquareAppModule);
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import io.bitsquare.arbitration.tomp2p.TomP2PArbitratorModule;
|
||||||
import io.bitsquare.btc.BitcoinModule;
|
import io.bitsquare.btc.BitcoinModule;
|
||||||
import io.bitsquare.crypto.CryptoModule;
|
import io.bitsquare.crypto.CryptoModule;
|
||||||
import io.bitsquare.gui.GuiModule;
|
import io.bitsquare.gui.GuiModule;
|
||||||
import io.bitsquare.p2p.NetworkModule;
|
import io.bitsquare.p2p.P2PModule;
|
||||||
import io.bitsquare.p2p.tomp2p.TomP2PModule;
|
import io.bitsquare.p2p.tomp2p.TomP2PModule;
|
||||||
import io.bitsquare.offer.OfferModule;
|
import io.bitsquare.offer.OfferModule;
|
||||||
import io.bitsquare.offer.tomp2p.TomP2POfferModule;
|
import io.bitsquare.offer.tomp2p.TomP2POfferModule;
|
||||||
|
|
@ -80,7 +80,7 @@ class BitsquareAppModule extends BitsquareModule {
|
||||||
return new TomP2PArbitratorModule(env);
|
return new TomP2PArbitratorModule(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected NetworkModule networkModule() {
|
protected P2PModule networkModule() {
|
||||||
return new TomP2PModule(env);
|
return new TomP2PModule(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import io.bitsquare.locale.LanguageUtil;
|
||||||
import io.bitsquare.p2p.BootstrapState;
|
import io.bitsquare.p2p.BootstrapState;
|
||||||
import io.bitsquare.p2p.ClientNode;
|
import io.bitsquare.p2p.ClientNode;
|
||||||
import io.bitsquare.p2p.MessageService;
|
import io.bitsquare.p2p.MessageService;
|
||||||
|
import io.bitsquare.p2p.P2PService;
|
||||||
import io.bitsquare.persistence.Persistence;
|
import io.bitsquare.persistence.Persistence;
|
||||||
import io.bitsquare.trade.Trade;
|
import io.bitsquare.trade.Trade;
|
||||||
import io.bitsquare.trade.TradeManager;
|
import io.bitsquare.trade.TradeManager;
|
||||||
|
|
@ -157,6 +158,9 @@ class MainViewModel implements ViewModel {
|
||||||
error -> log.error(error.toString()),
|
error -> log.error(error.toString()),
|
||||||
() -> Platform.runLater(() -> setBitcoinNetworkSyncProgress(1.0)));
|
() -> Platform.runLater(() -> setBitcoinNetworkSyncProgress(1.0)));
|
||||||
|
|
||||||
|
// Set executor for all P2PServices
|
||||||
|
P2PService.setUserThread(Platform::runLater);
|
||||||
|
|
||||||
Observable<BootstrapState> bootstrapStateAsObservable = clientNode.bootstrap(user.getMessageKeyPair());
|
Observable<BootstrapState> bootstrapStateAsObservable = clientNode.bootstrap(user.getMessageKeyPair());
|
||||||
bootstrapStateAsObservable.publish();
|
bootstrapStateAsObservable.publish();
|
||||||
bootstrapStateAsObservable.subscribe(
|
bootstrapStateAsObservable.subscribe(
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,14 @@ public abstract class OfferModule extends BitsquareModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected final void configure()
|
||||||
|
{
|
||||||
bind(OfferBook.class).in(Singleton.class);
|
bind(OfferBook.class).in(Singleton.class);
|
||||||
bind(OfferBook.class).in(Singleton.class);
|
bind(OfferBook.class).in(Singleton.class);
|
||||||
|
|
||||||
|
doConfigure();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doConfigure() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,7 @@ public class TomP2POfferModule extends OfferModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void doConfigure() {
|
||||||
super.configure();
|
|
||||||
bind(OfferBookService.class).to(TomP2POfferBookService.class).in(Singleton.class);
|
bind(OfferBookService.class).to(TomP2POfferBookService.class).in(Singleton.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,9 +21,9 @@ import io.bitsquare.BitsquareModule;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
|
||||||
public abstract class NetworkModule extends BitsquareModule {
|
public abstract class P2PModule extends BitsquareModule {
|
||||||
|
|
||||||
protected NetworkModule(Environment env) {
|
protected P2PModule(Environment env) {
|
||||||
super(env);
|
super(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -19,10 +19,26 @@ package io.bitsquare.p2p;
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
public interface P2PService {
|
import net.tomp2p.dht.PeerDHT;
|
||||||
void setExecutor(Executor executor);
|
|
||||||
|
|
||||||
void bootstrapCompleted();
|
public class P2PService {
|
||||||
|
|
||||||
void shutDown();
|
private static Executor userThread;
|
||||||
|
|
||||||
|
public static void setUserThread(Executor userThread) {
|
||||||
|
P2PService.userThread = userThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Executor executor = userThread;
|
||||||
|
protected PeerDHT peerDHT;
|
||||||
|
|
||||||
|
public void bootstrapCompleted() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExecutor(Executor executor) {
|
||||||
|
this.executor = executor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void shutDown() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import io.bitsquare.p2p.AddressService;
|
||||||
import io.bitsquare.p2p.BootstrapNodes;
|
import io.bitsquare.p2p.BootstrapNodes;
|
||||||
import io.bitsquare.p2p.ClientNode;
|
import io.bitsquare.p2p.ClientNode;
|
||||||
import io.bitsquare.p2p.MessageService;
|
import io.bitsquare.p2p.MessageService;
|
||||||
import io.bitsquare.p2p.NetworkModule;
|
import io.bitsquare.p2p.P2PModule;
|
||||||
import io.bitsquare.p2p.Node;
|
import io.bitsquare.p2p.Node;
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
|
@ -32,7 +32,7 @@ import org.springframework.core.env.Environment;
|
||||||
|
|
||||||
import static io.bitsquare.p2p.tomp2p.BootstrappedPeerBuilder.*;
|
import static io.bitsquare.p2p.tomp2p.BootstrappedPeerBuilder.*;
|
||||||
|
|
||||||
public class TomP2PModule extends NetworkModule {
|
public class TomP2PModule extends P2PModule {
|
||||||
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";
|
||||||
|
|
@ -69,8 +69,6 @@ public class TomP2PModule extends NetworkModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doClose(Injector injector) {
|
protected void doClose(Injector injector) {
|
||||||
super.doClose(injector);
|
|
||||||
|
|
||||||
// First shut down AddressService to remove address from DHT
|
// First shut down AddressService to remove address from DHT
|
||||||
injector.getInstance(AddressService.class).shutDown();
|
injector.getInstance(AddressService.class).shutDown();
|
||||||
injector.getInstance(BootstrappedPeerBuilder.class).shutDown();
|
injector.getInstance(BootstrappedPeerBuilder.class).shutDown();
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,8 @@ package io.bitsquare.p2p.tomp2p;
|
||||||
import io.bitsquare.p2p.BootstrapState;
|
import io.bitsquare.p2p.BootstrapState;
|
||||||
import io.bitsquare.p2p.P2PService;
|
import io.bitsquare.p2p.P2PService;
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import net.tomp2p.dht.PeerDHT;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
@ -40,21 +36,11 @@ import rx.Subscriber;
|
||||||
* That way we limit the dependency of the TomP2P library only to that class (and it's sub components).
|
* That way we limit the dependency of the TomP2P library only to that class (and it's sub components).
|
||||||
* <p/>
|
* <p/>
|
||||||
*/
|
*/
|
||||||
public class TomP2PService implements P2PService {
|
public class TomP2PService extends P2PService {
|
||||||
private static final Logger log = LoggerFactory.getLogger(TomP2PService.class);
|
private static final Logger log = LoggerFactory.getLogger(TomP2PService.class);
|
||||||
|
|
||||||
private static Executor userThread;
|
|
||||||
|
|
||||||
// Set to Platform::runLater from app to get all callbacks on the userThread
|
|
||||||
public static void setUserThread(Executor userThread) {
|
|
||||||
TomP2PService.userThread = userThread;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Subscriber<BootstrapState> subscriber;
|
private final Subscriber<BootstrapState> subscriber;
|
||||||
|
|
||||||
protected Executor executor = userThread;
|
|
||||||
protected PeerDHT peerDHT;
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
|
|
@ -83,19 +69,4 @@ public class TomP2PService implements P2PService {
|
||||||
};
|
};
|
||||||
bootstrapStateAsObservable.subscribe(subscriber);
|
bootstrapStateAsObservable.subscribe(subscriber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void bootstrapCompleted() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setExecutor(Executor executor) {
|
|
||||||
this.executor = executor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void shutDown() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue