mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-21 08:06:33 -04:00
Renamed NetworkModule to P2PModule
This commit is contained in:
parent
5b090cf7b8
commit
79698df651
@ -26,7 +26,6 @@ import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.gui.main.MainView;
|
||||
import io.bitsquare.gui.main.debug.DebugView;
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
import io.bitsquare.p2p.tomp2p.TomP2PService;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.user.AccountSettings;
|
||||
import io.bitsquare.user.User;
|
||||
@ -40,7 +39,6 @@ import com.google.inject.Injector;
|
||||
import java.io.IOException;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.*;
|
||||
import javafx.scene.image.*;
|
||||
import javafx.scene.input.*;
|
||||
@ -74,7 +72,6 @@ public class BitsquareApp extends Application {
|
||||
this.primaryStage = primaryStage;
|
||||
|
||||
log.trace("BitsquareApp.start");
|
||||
TomP2PService.setUserThread(Platform::runLater);
|
||||
|
||||
bitsquareAppModule = new BitsquareAppModule(env, primaryStage);
|
||||
injector = Guice.createInjector(bitsquareAppModule);
|
||||
|
@ -23,7 +23,7 @@ import io.bitsquare.arbitration.tomp2p.TomP2PArbitratorModule;
|
||||
import io.bitsquare.btc.BitcoinModule;
|
||||
import io.bitsquare.crypto.CryptoModule;
|
||||
import io.bitsquare.gui.GuiModule;
|
||||
import io.bitsquare.p2p.NetworkModule;
|
||||
import io.bitsquare.p2p.P2PModule;
|
||||
import io.bitsquare.p2p.tomp2p.TomP2PModule;
|
||||
import io.bitsquare.offer.OfferModule;
|
||||
import io.bitsquare.offer.tomp2p.TomP2POfferModule;
|
||||
@ -80,7 +80,7 @@ class BitsquareAppModule extends BitsquareModule {
|
||||
return new TomP2PArbitratorModule(env);
|
||||
}
|
||||
|
||||
protected NetworkModule networkModule() {
|
||||
protected P2PModule networkModule() {
|
||||
return new TomP2PModule(env);
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ import io.bitsquare.locale.LanguageUtil;
|
||||
import io.bitsquare.p2p.BootstrapState;
|
||||
import io.bitsquare.p2p.ClientNode;
|
||||
import io.bitsquare.p2p.MessageService;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
@ -157,6 +158,9 @@ class MainViewModel implements ViewModel {
|
||||
error -> log.error(error.toString()),
|
||||
() -> Platform.runLater(() -> setBitcoinNetworkSyncProgress(1.0)));
|
||||
|
||||
// Set executor for all P2PServices
|
||||
P2PService.setUserThread(Platform::runLater);
|
||||
|
||||
Observable<BootstrapState> bootstrapStateAsObservable = clientNode.bootstrap(user.getMessageKeyPair());
|
||||
bootstrapStateAsObservable.publish();
|
||||
bootstrapStateAsObservable.subscribe(
|
||||
|
@ -30,9 +30,14 @@ public abstract class OfferModule extends BitsquareModule {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
protected final void configure()
|
||||
{
|
||||
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
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
protected void doConfigure() {
|
||||
bind(OfferBookService.class).to(TomP2POfferBookService.class).in(Singleton.class);
|
||||
}
|
||||
}
|
@ -21,9 +21,9 @@ import io.bitsquare.BitsquareModule;
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -19,10 +19,26 @@ package io.bitsquare.p2p;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public interface P2PService {
|
||||
void setExecutor(Executor executor);
|
||||
import net.tomp2p.dht.PeerDHT;
|
||||
|
||||
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.ClientNode;
|
||||
import io.bitsquare.p2p.MessageService;
|
||||
import io.bitsquare.p2p.NetworkModule;
|
||||
import io.bitsquare.p2p.P2PModule;
|
||||
import io.bitsquare.p2p.Node;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
@ -32,7 +32,7 @@ import org.springframework.core.env.Environment;
|
||||
|
||||
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_IP_KEY = "bootstrap.node.ip";
|
||||
public static final String BOOTSTRAP_NODE_PORT_KEY = "bootstrap.node.port";
|
||||
@ -69,8 +69,6 @@ public class TomP2PModule extends NetworkModule {
|
||||
|
||||
@Override
|
||||
protected void doClose(Injector injector) {
|
||||
super.doClose(injector);
|
||||
|
||||
// First shut down AddressService to remove address from DHT
|
||||
injector.getInstance(AddressService.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.P2PService;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import net.tomp2p.dht.PeerDHT;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
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).
|
||||
* <p/>
|
||||
*/
|
||||
public class TomP2PService implements P2PService {
|
||||
public class TomP2PService extends P2PService {
|
||||
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;
|
||||
|
||||
protected Executor executor = userThread;
|
||||
protected PeerDHT peerDHT;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
@ -83,19 +69,4 @@ public class TomP2PService implements P2PService {
|
||||
};
|
||||
bootstrapStateAsObservable.subscribe(subscriber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bootstrapCompleted() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExecutor(Executor executor) {
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutDown() {
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user