mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-20 23:56:30 -04:00
Refactor TomP2P services
This commit is contained in:
parent
3f12247d65
commit
2f2d6b68e0
@ -40,7 +40,7 @@ import joptsimple.OptionSet;
|
||||
|
||||
import static io.bitsquare.app.BitsquareEnvironment.*;
|
||||
import static io.bitsquare.network.Node.*;
|
||||
import static io.bitsquare.network.tomp2p.TomP2PNetworkModule.*;
|
||||
import static io.bitsquare.network.tomp2p.TomP2PModule.*;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class BitsquareAppMain extends BitsquareExecutable {
|
||||
|
@ -18,13 +18,13 @@
|
||||
package io.bitsquare.app;
|
||||
|
||||
import io.bitsquare.BitsquareModule;
|
||||
import io.bitsquare.arbitration.ArbitratorMessageModule;
|
||||
import io.bitsquare.arbitration.tomp2p.TomP2PArbitratorMessageModule;
|
||||
import io.bitsquare.arbitration.ArbitratorModule;
|
||||
import io.bitsquare.arbitration.tomp2p.TomP2PArbitratorModule;
|
||||
import io.bitsquare.btc.BitcoinModule;
|
||||
import io.bitsquare.crypto.CryptoModule;
|
||||
import io.bitsquare.gui.GuiModule;
|
||||
import io.bitsquare.network.NetworkModule;
|
||||
import io.bitsquare.network.tomp2p.TomP2PNetworkModule;
|
||||
import io.bitsquare.network.tomp2p.TomP2PModule;
|
||||
import io.bitsquare.offer.OfferModule;
|
||||
import io.bitsquare.offer.tomp2p.TomP2POfferModule;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
@ -76,12 +76,12 @@ class BitsquareAppModule extends BitsquareModule {
|
||||
install(guiModule());
|
||||
}
|
||||
|
||||
protected ArbitratorMessageModule arbitratorMessageModule() {
|
||||
return new TomP2PArbitratorMessageModule(env);
|
||||
protected ArbitratorModule arbitratorMessageModule() {
|
||||
return new TomP2PArbitratorModule(env);
|
||||
}
|
||||
|
||||
protected NetworkModule networkModule() {
|
||||
return new TomP2PNetworkModule(env);
|
||||
return new TomP2PModule(env);
|
||||
}
|
||||
|
||||
protected BitcoinModule bitcoinModule() {
|
||||
|
@ -21,9 +21,9 @@ import io.bitsquare.BitsquareModule;
|
||||
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
public abstract class ArbitratorMessageModule extends BitsquareModule {
|
||||
public abstract class ArbitratorModule extends BitsquareModule {
|
||||
|
||||
protected ArbitratorMessageModule(Environment env) {
|
||||
protected ArbitratorModule(Environment env) {
|
||||
super(env);
|
||||
}
|
||||
|
@ -22,11 +22,8 @@ import io.bitsquare.arbitration.listeners.ArbitratorListener;
|
||||
import io.bitsquare.network.DHTService;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public interface ArbitratorService extends DHTService {
|
||||
void setExecutor(Executor executor);
|
||||
|
||||
void addArbitrator(Arbitrator arbitrator);
|
||||
|
||||
void addArbitratorListener(ArbitratorListener listener);
|
||||
|
@ -17,16 +17,16 @@
|
||||
|
||||
package io.bitsquare.arbitration.tomp2p;
|
||||
|
||||
import io.bitsquare.arbitration.ArbitratorMessageModule;
|
||||
import io.bitsquare.arbitration.ArbitratorModule;
|
||||
import io.bitsquare.arbitration.ArbitratorService;
|
||||
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
public class TomP2PArbitratorMessageModule extends ArbitratorMessageModule {
|
||||
public class TomP2PArbitratorModule extends ArbitratorModule {
|
||||
|
||||
public TomP2PArbitratorMessageModule(Environment env) {
|
||||
public TomP2PArbitratorModule(Environment env) {
|
||||
super(env);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import net.tomp2p.dht.FutureRemove;
|
||||
import net.tomp2p.peers.Number160;
|
||||
import net.tomp2p.storage.Data;
|
||||
|
||||
public interface DHTService extends NetworkService {
|
||||
public interface DHTService extends P2PService {
|
||||
|
||||
FuturePut putDomainProtectedData(Number160 locationKey, Data data);
|
||||
|
||||
|
@ -20,7 +20,7 @@ package io.bitsquare.network;
|
||||
|
||||
import io.bitsquare.network.listener.SendMessageListener;
|
||||
|
||||
public interface MessageService extends NetworkService, MessageHandler {
|
||||
public interface MessageService extends P2PService, MessageHandler {
|
||||
|
||||
void sendMessage(Peer peer, Message message, SendMessageListener listener);
|
||||
|
||||
|
@ -19,7 +19,7 @@ package io.bitsquare.network;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public interface NetworkService {
|
||||
public interface P2PService {
|
||||
void setExecutor(Executor executor);
|
||||
|
||||
void bootstrapCompleted();
|
@ -32,14 +32,14 @@ import org.springframework.core.env.Environment;
|
||||
|
||||
import static io.bitsquare.network.tomp2p.BootstrappedPeerBuilder.*;
|
||||
|
||||
public class TomP2PNetworkModule extends NetworkModule {
|
||||
public class TomP2PModule extends NetworkModule {
|
||||
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 = BootstrappedPeerBuilder.NETWORK_INTERFACE_KEY;
|
||||
public static final String USE_MANUAL_PORT_FORWARDING_KEY = BootstrappedPeerBuilder.USE_MANUAL_PORT_FORWARDING_KEY;
|
||||
|
||||
public TomP2PNetworkModule(Environment env) {
|
||||
public TomP2PModule(Environment env) {
|
||||
super(env);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
package io.bitsquare.network.tomp2p;
|
||||
|
||||
import io.bitsquare.network.BootstrapState;
|
||||
import io.bitsquare.network.NetworkService;
|
||||
import io.bitsquare.network.P2PService;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@ -42,7 +42,7 @@ 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 NetworkService {
|
||||
public class TomP2PService implements P2PService {
|
||||
private static final Logger log = LoggerFactory.getLogger(TomP2PService.class);
|
||||
|
||||
private final Subscriber<BootstrapState> subscriber;
|
||||
|
@ -17,17 +17,11 @@
|
||||
|
||||
package io.bitsquare.offer.tomp2p;
|
||||
|
||||
import io.bitsquare.network.tomp2p.TomP2PNode;
|
||||
import io.bitsquare.offer.OfferBookService;
|
||||
import io.bitsquare.offer.OfferModule;
|
||||
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import javafx.application.Platform;
|
||||
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
public class TomP2POfferModule extends OfferModule {
|
||||
@ -39,20 +33,6 @@ public class TomP2POfferModule extends OfferModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
bind(OfferBookService.class).toProvider(OfferBookServiceProvider.class).in(Singleton.class);
|
||||
}
|
||||
}
|
||||
|
||||
class OfferBookServiceProvider implements Provider<OfferBookService> {
|
||||
private final OfferBookService offerBookService;
|
||||
|
||||
@Inject
|
||||
public OfferBookServiceProvider(TomP2PNode tomP2PNode) {
|
||||
offerBookService = new TomP2POfferBookService(tomP2PNode);
|
||||
offerBookService.setExecutor(Platform::runLater);
|
||||
}
|
||||
|
||||
public OfferBookService get() {
|
||||
return offerBookService;
|
||||
bind(OfferBookService.class).to(TomP2POfferBookService.class).in(Singleton.class);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user