Search in sources :

Example 31 with NodeAddress

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);
    }
}
Also used : NodeAddress(io.bitsquare.p2p.NodeAddress)

Example 32 with NodeAddress

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);
    }
}
Also used : NodeAddress(io.bitsquare.p2p.NodeAddress)

Example 33 with NodeAddress

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;
    }
}
Also used : NodeAddress(io.bitsquare.p2p.NodeAddress) Before(org.junit.Before)

Example 34 with NodeAddress

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;
}
Also used : P2PServiceListener(io.bitsquare.p2p.P2PServiceListener) DummySeedNode(io.bitsquare.p2p.DummySeedNode) NodeAddress(io.bitsquare.p2p.NodeAddress) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

NodeAddress (io.bitsquare.p2p.NodeAddress)34 WalletService (io.bitsquare.btc.WalletService)5 Contract (io.bitsquare.trade.Contract)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 Log (io.bitsquare.app.Log)4 AddressEntry (io.bitsquare.btc.AddressEntry)4 Timer (io.bitsquare.common.Timer)4 UserThread (io.bitsquare.common.UserThread)4 PubKeyRing (io.bitsquare.common.crypto.PubKeyRing)4 P2PService (io.bitsquare.p2p.P2PService)4 SendMailboxMessageListener (io.bitsquare.p2p.messaging.SendMailboxMessageListener)4 TimeUnit (java.util.concurrent.TimeUnit)4 DummySeedNode (io.bitsquare.p2p.DummySeedNode)3 P2PServiceListener (io.bitsquare.p2p.P2PServiceListener)3 Connection (io.bitsquare.p2p.network.Connection)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 Collectors (java.util.stream.Collectors)3 FutureCallback (com.google.common.util.concurrent.FutureCallback)2 Futures (com.google.common.util.concurrent.Futures)2