mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-09 23:52:48 -04:00
Renamed DHTService to AddressService
This commit is contained in:
parent
a2654d20b9
commit
1893953948
6 changed files with 25 additions and 25 deletions
|
@ -24,7 +24,7 @@ import java.security.PublicKey;
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
public interface DHTService {
|
public interface AddressService {
|
||||||
void setExecutor(Executor executor);
|
void setExecutor(Executor executor);
|
||||||
|
|
||||||
void findPeerAddress(PublicKey messagePublicKey, GetPeerAddressListener getPeerAddressListener);
|
void findPeerAddress(PublicKey messagePublicKey, GetPeerAddressListener getPeerAddressListener);
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
package io.bitsquare.network.tomp2p;
|
package io.bitsquare.network.tomp2p;
|
||||||
|
|
||||||
import io.bitsquare.network.DHTService;
|
import io.bitsquare.network.AddressService;
|
||||||
import io.bitsquare.network.MessageHandler;
|
import io.bitsquare.network.MessageHandler;
|
||||||
import io.bitsquare.network.Peer;
|
import io.bitsquare.network.Peer;
|
||||||
import io.bitsquare.network.listener.GetPeerAddressListener;
|
import io.bitsquare.network.listener.GetPeerAddressListener;
|
||||||
|
@ -44,8 +44,8 @@ import org.slf4j.LoggerFactory;
|
||||||
* 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 TomP2PDHTService implements DHTService {
|
public class TomP2PAddressService implements AddressService {
|
||||||
private static final Logger log = LoggerFactory.getLogger(TomP2PDHTService.class);
|
private static final Logger log = LoggerFactory.getLogger(TomP2PAddressService.class);
|
||||||
|
|
||||||
private final TomP2PNode tomP2PNode;
|
private final TomP2PNode tomP2PNode;
|
||||||
private final CopyOnWriteArrayList<MessageHandler> messageHandlers = new CopyOnWriteArrayList<>();
|
private final CopyOnWriteArrayList<MessageHandler> messageHandlers = new CopyOnWriteArrayList<>();
|
||||||
|
@ -56,7 +56,7 @@ public class TomP2PDHTService implements DHTService {
|
||||||
// Constructor
|
// Constructor
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public TomP2PDHTService(TomP2PNode tomP2PNode) {
|
public TomP2PAddressService(TomP2PNode tomP2PNode) {
|
||||||
this.tomP2PNode = tomP2PNode;
|
this.tomP2PNode = tomP2PNode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ package io.bitsquare.network.tomp2p;
|
||||||
|
|
||||||
import io.bitsquare.network.BootstrapNodes;
|
import io.bitsquare.network.BootstrapNodes;
|
||||||
import io.bitsquare.network.ClientNode;
|
import io.bitsquare.network.ClientNode;
|
||||||
import io.bitsquare.network.DHTService;
|
import io.bitsquare.network.AddressService;
|
||||||
import io.bitsquare.network.MessageService;
|
import io.bitsquare.network.MessageService;
|
||||||
import io.bitsquare.network.NetworkModule;
|
import io.bitsquare.network.NetworkModule;
|
||||||
import io.bitsquare.network.Node;
|
import io.bitsquare.network.Node;
|
||||||
|
@ -53,7 +53,7 @@ public class TomP2PNetworkModule extends NetworkModule {
|
||||||
bind(ClientNode.class).to(TomP2PNode.class).in(Singleton.class);
|
bind(ClientNode.class).to(TomP2PNode.class).in(Singleton.class);
|
||||||
bind(TomP2PNode.class).in(Singleton.class);
|
bind(TomP2PNode.class).in(Singleton.class);
|
||||||
bind(MessageService.class).toProvider(TomP2PMessageServiceProvider.class).in(Singleton.class);
|
bind(MessageService.class).toProvider(TomP2PMessageServiceProvider.class).in(Singleton.class);
|
||||||
bind(DHTService.class).toProvider(TomP2PDHTServiceProvider.class).in(Singleton.class);
|
bind(AddressService.class).toProvider(TomP2PAddressServiceProvider.class).in(Singleton.class);
|
||||||
|
|
||||||
bind(int.class).annotatedWith(Names.named(Node.PORT_KEY)).toInstance(env.getProperty(Node.PORT_KEY, int.class, Node.DEFAULT_PORT));
|
bind(int.class).annotatedWith(Names.named(Node.PORT_KEY)).toInstance(env.getProperty(Node.PORT_KEY, int.class, Node.DEFAULT_PORT));
|
||||||
bind(boolean.class).annotatedWith(Names.named(USE_MANUAL_PORT_FORWARDING_KEY)).toInstance(
|
bind(boolean.class).annotatedWith(Names.named(USE_MANUAL_PORT_FORWARDING_KEY)).toInstance(
|
||||||
|
@ -93,16 +93,16 @@ class TomP2PMessageServiceProvider implements Provider<MessageService> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TomP2PDHTServiceProvider implements Provider<DHTService> {
|
class TomP2PAddressServiceProvider implements Provider<AddressService> {
|
||||||
private final DHTService dhtService;
|
private final AddressService addressService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TomP2PDHTServiceProvider(TomP2PNode tomP2PNode) {
|
public TomP2PAddressServiceProvider(TomP2PNode tomP2PNode) {
|
||||||
dhtService = new TomP2PDHTService(tomP2PNode);
|
addressService = new TomP2PAddressService(tomP2PNode);
|
||||||
dhtService.setExecutor(Platform::runLater);
|
addressService.setExecutor(Platform::runLater);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DHTService get() {
|
public AddressService get() {
|
||||||
return dhtService;
|
return addressService;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,7 +23,7 @@ import io.bitsquare.common.handlers.ErrorMessageHandler;
|
||||||
import io.bitsquare.common.handlers.ResultHandler;
|
import io.bitsquare.common.handlers.ResultHandler;
|
||||||
import io.bitsquare.crypto.SignatureService;
|
import io.bitsquare.crypto.SignatureService;
|
||||||
import io.bitsquare.fiat.FiatAccount;
|
import io.bitsquare.fiat.FiatAccount;
|
||||||
import io.bitsquare.network.DHTService;
|
import io.bitsquare.network.AddressService;
|
||||||
import io.bitsquare.network.Message;
|
import io.bitsquare.network.Message;
|
||||||
import io.bitsquare.network.MessageService;
|
import io.bitsquare.network.MessageService;
|
||||||
import io.bitsquare.network.Peer;
|
import io.bitsquare.network.Peer;
|
||||||
|
@ -72,7 +72,7 @@ public class TradeManager {
|
||||||
private final AccountSettings accountSettings;
|
private final AccountSettings accountSettings;
|
||||||
private final Persistence persistence;
|
private final Persistence persistence;
|
||||||
private final MessageService messageService;
|
private final MessageService messageService;
|
||||||
private final DHTService dhtService;
|
private final AddressService addressService;
|
||||||
private final BlockChainService blockChainService;
|
private final BlockChainService blockChainService;
|
||||||
private final WalletService walletService;
|
private final WalletService walletService;
|
||||||
private final SignatureService signatureService;
|
private final SignatureService signatureService;
|
||||||
|
@ -95,14 +95,14 @@ public class TradeManager {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TradeManager(User user, AccountSettings accountSettings, Persistence persistence,
|
public TradeManager(User user, AccountSettings accountSettings, Persistence persistence,
|
||||||
MessageService messageService, DHTService dhtService, BlockChainService blockChainService,
|
MessageService messageService, AddressService addressService, BlockChainService blockChainService,
|
||||||
WalletService walletService, SignatureService signatureService,
|
WalletService walletService, SignatureService signatureService,
|
||||||
OfferBookService offerBookService) {
|
OfferBookService offerBookService) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.accountSettings = accountSettings;
|
this.accountSettings = accountSettings;
|
||||||
this.persistence = persistence;
|
this.persistence = persistence;
|
||||||
this.messageService = messageService;
|
this.messageService = messageService;
|
||||||
this.dhtService = dhtService;
|
this.addressService = addressService;
|
||||||
this.blockChainService = blockChainService;
|
this.blockChainService = blockChainService;
|
||||||
this.walletService = walletService;
|
this.walletService = walletService;
|
||||||
this.signatureService = signatureService;
|
this.signatureService = signatureService;
|
||||||
|
@ -152,7 +152,7 @@ public class TradeManager {
|
||||||
CheckOfferAvailabilityModel model = new CheckOfferAvailabilityModel(
|
CheckOfferAvailabilityModel model = new CheckOfferAvailabilityModel(
|
||||||
offer,
|
offer,
|
||||||
messageService,
|
messageService,
|
||||||
dhtService);
|
addressService);
|
||||||
|
|
||||||
CheckOfferAvailabilityProtocol protocol = new CheckOfferAvailabilityProtocol(model,
|
CheckOfferAvailabilityProtocol protocol = new CheckOfferAvailabilityProtocol(model,
|
||||||
() -> disposeCheckOfferAvailabilityRequest(offer),
|
() -> disposeCheckOfferAvailabilityRequest(offer),
|
||||||
|
@ -215,7 +215,7 @@ public class TradeManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestTakeOffer(Coin amount, Offer offer, TradeResultHandler tradeResultHandler) {
|
public void requestTakeOffer(Coin amount, Offer offer, TradeResultHandler tradeResultHandler) {
|
||||||
CheckOfferAvailabilityModel model = new CheckOfferAvailabilityModel(offer, messageService, dhtService);
|
CheckOfferAvailabilityModel model = new CheckOfferAvailabilityModel(offer, messageService, addressService);
|
||||||
CheckOfferAvailabilityProtocol protocol = new CheckOfferAvailabilityProtocol(model,
|
CheckOfferAvailabilityProtocol protocol = new CheckOfferAvailabilityProtocol(model,
|
||||||
() -> {
|
() -> {
|
||||||
disposeCheckOfferAvailabilityRequest(offer);
|
disposeCheckOfferAvailabilityRequest(offer);
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
package io.bitsquare.trade.protocol.availability;
|
package io.bitsquare.trade.protocol.availability;
|
||||||
|
|
||||||
import io.bitsquare.common.taskrunner.SharedTaskModel;
|
import io.bitsquare.common.taskrunner.SharedTaskModel;
|
||||||
import io.bitsquare.network.DHTService;
|
import io.bitsquare.network.AddressService;
|
||||||
import io.bitsquare.network.MessageService;
|
import io.bitsquare.network.MessageService;
|
||||||
import io.bitsquare.network.Peer;
|
import io.bitsquare.network.Peer;
|
||||||
import io.bitsquare.offer.Offer;
|
import io.bitsquare.offer.Offer;
|
||||||
|
@ -32,15 +32,15 @@ public class CheckOfferAvailabilityModel extends SharedTaskModel {
|
||||||
|
|
||||||
public final Offer offer;
|
public final Offer offer;
|
||||||
public final MessageService messageService;
|
public final MessageService messageService;
|
||||||
public final DHTService dhtService;
|
public final AddressService addressService;
|
||||||
|
|
||||||
private Peer peer;
|
private Peer peer;
|
||||||
private OfferMessage message;
|
private OfferMessage message;
|
||||||
|
|
||||||
public CheckOfferAvailabilityModel(Offer offer, MessageService messageService, DHTService dhtService) {
|
public CheckOfferAvailabilityModel(Offer offer, MessageService messageService, AddressService addressService) {
|
||||||
this.offer = offer;
|
this.offer = offer;
|
||||||
this.messageService = messageService;
|
this.messageService = messageService;
|
||||||
this.dhtService = dhtService;
|
this.addressService = addressService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Peer getPeer() {
|
public Peer getPeer() {
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class GetPeerAddress extends Task<CheckOfferAvailabilityModel> {
|
||||||
@Override
|
@Override
|
||||||
protected void doRun() {
|
protected void doRun() {
|
||||||
try {
|
try {
|
||||||
model.dhtService.findPeerAddress(model.offer.getMessagePublicKey(), new GetPeerAddressListener() {
|
model.addressService.findPeerAddress(model.offer.getMessagePublicKey(), new GetPeerAddressListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onResult(Peer peer) {
|
public void onResult(Peer peer) {
|
||||||
model.setPeer(peer);
|
model.setPeer(peer);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue