use of io.bitsquare.p2p.NodeAddress in project bitsquare by bitsquare.
the class RequestDataManager method closeHandler.
private void closeHandler(Connection connection) {
Optional<NodeAddress> peersNodeAddressOptional = connection.getPeersNodeAddressOptional();
if (peersNodeAddressOptional.isPresent()) {
NodeAddress nodeAddress = peersNodeAddressOptional.get();
if (handlerMap.containsKey(nodeAddress)) {
handlerMap.get(nodeAddress).cancel();
handlerMap.remove(nodeAddress);
}
} else {
log.trace("closeRequestDataHandler: nodeAddress not set in connection " + connection);
}
}
use of io.bitsquare.p2p.NodeAddress in project bitsquare by bitsquare.
the class RequestDataManager method requestUpdateData.
public void requestUpdateData() {
Log.traceCall();
checkArgument(nodeAddressOfPreliminaryDataRequest.isPresent(), "nodeAddressOfPreliminaryDataRequest must be present");
dataUpdateRequested = true;
List<NodeAddress> remainingNodeAddresses = new ArrayList<>(seedNodeAddresses);
if (!remainingNodeAddresses.isEmpty()) {
Collections.shuffle(remainingNodeAddresses);
NodeAddress candidate = nodeAddressOfPreliminaryDataRequest.get();
remainingNodeAddresses.remove(candidate);
isPreliminaryDataRequest = false;
requestData(candidate, remainingNodeAddresses);
}
}
use of io.bitsquare.p2p.NodeAddress in project bitsquare by bitsquare.
the class PeerManagerTest method setup.
@Before
public void setup() throws InterruptedException {
LocalhostNetworkNode.setSimulateTorDelayTorNode(50);
LocalhostNetworkNode.setSimulateTorDelayHiddenService(8);
seedNodes = new HashSet<>();
if (useLocalhost) {
//seedNodes.add(new Address("localhost:8001"));
// seedNodes.add(new Address("localhost:8002"));
seedNodes.add(new NodeAddress("localhost:8003"));
sleepTime = 100;
} else {
seedNodes.add(new NodeAddress("3omjuxn7z73pxoee.onion:8001"));
seedNodes.add(new NodeAddress("j24fxqyghjetgpdx.onion:8002"));
seedNodes.add(new NodeAddress("45367tl6unwec6kw.onion:8003"));
sleepTime = 1000;
}
}
use of io.bitsquare.p2p.NodeAddress in project bitsquare by bitsquare.
the class PeerManagerTest method getAndStartSeedNode.
private DummySeedNode getAndStartSeedNode(int port) throws InterruptedException {
DummySeedNode seedNode = new DummySeedNode("test_dummy_dir");
latch = new CountDownLatch(1);
seedNode.createAndStartP2PService(new NodeAddress("localhost", port), MAX_CONNECTIONS, useLocalhost, 2, true, seedNodes, new P2PServiceListener() {
@Override
public void onRequestingDataCompleted() {
latch.countDown();
}
@Override
public void onNoSeedNodeAvailable() {
}
@Override
public void onTorNodeReady() {
}
@Override
public void onNoPeersAvailable() {
}
@Override
public void onBootstrapComplete() {
}
@Override
public void onHiddenServicePublished() {
}
@Override
public void onSetupFailed(Throwable throwable) {
}
});
latch.await();
Thread.sleep(sleepTime);
return seedNode;
}
Aggregations