From b254ad234ac63e7abc6ce8ed97151b5836b5eb56 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 14 Oct 2014 22:32:10 +0200 Subject: [PATCH 1/2] Upgrade to new TomP2P snapshot --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c936a989be..0b916d6156 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ repositories { dependencies { compile 'org.bitcoinj:bitcoinj-core:0.12' - compile 'net.tomp2p:tomp2p-all:5.0-Alpha24.805623c-SNAPSHOT' + compile 'net.tomp2p:tomp2p-all:5.0-Alpha25.55844fb-SNAPSHOT' compile 'com.typesafe.akka:akka-actor_2.10:2.3.4' compile 'org.slf4j:slf4j-api:1.7.7' compile 'ch.qos.logback:logback-core:1.1.2' From 68fc89f3f62b0232131d273a7b32d29c78e73aa4 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Tue, 14 Oct 2014 22:44:20 +0200 Subject: [PATCH 2/2] Update to changes in TomP2P snapshot 25 API --- src/main/java/io/bitsquare/SeedNode.java | 4 +- .../io/bitsquare/msg/actor/DHTManager.java | 5 ++- src/test/java/io/bitsquare/msg/UtilsDHT2.java | 39 +++++++++++-------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/main/java/io/bitsquare/SeedNode.java b/src/main/java/io/bitsquare/SeedNode.java index 53b22eaef7..55a996d64b 100644 --- a/src/main/java/io/bitsquare/SeedNode.java +++ b/src/main/java/io/bitsquare/SeedNode.java @@ -35,6 +35,7 @@ import net.tomp2p.peers.PeerAddress; import net.tomp2p.peers.PeerMapChangeListener; import net.tomp2p.peers.PeerStatatistic; import net.tomp2p.relay.FutureRelay; +import net.tomp2p.relay.RconRPC; import net.tomp2p.relay.RelayRPC; import org.slf4j.Logger; @@ -114,7 +115,8 @@ public class SeedNode extends Thread { // Need to add all features the clients will use (otherwise msg type is UNKNOWN_ID) new PeerBuilderDHT(peer).start(); PeerNAT nodeBehindNat = new PeerBuilderNAT(peer).start(); - new RelayRPC(peer); + RconRPC rconRPC = new RconRPC(peer); + new RelayRPC(peer, rconRPC); //new PeerBuilderTracker(peer); nodeBehindNat.startSetupRelay(new FutureRelay()); diff --git a/src/main/java/io/bitsquare/msg/actor/DHTManager.java b/src/main/java/io/bitsquare/msg/actor/DHTManager.java index 2b97595f6f..eab9db2ae1 100644 --- a/src/main/java/io/bitsquare/msg/actor/DHTManager.java +++ b/src/main/java/io/bitsquare/msg/actor/DHTManager.java @@ -29,8 +29,8 @@ import net.tomp2p.nat.PeerBuilderNAT; import net.tomp2p.nat.PeerNAT; import net.tomp2p.p2p.Peer; import net.tomp2p.p2p.PeerBuilder; -import net.tomp2p.peers.Number160; import net.tomp2p.relay.FutureRelay; +import net.tomp2p.relay.RconRPC; import net.tomp2p.relay.RelayRPC; import akka.actor.AbstractActor; @@ -73,7 +73,8 @@ public class DHTManager extends AbstractActor { // Need to add all features the clients will use (otherwise msg type is UNKNOWN_ID) peerDHT = new PeerBuilderDHT(peer).start(); PeerNAT nodeBehindNat = new PeerBuilderNAT(peer).start(); - new RelayRPC(peer); + RconRPC rconRPC = new RconRPC(peer); + new RelayRPC(peer, rconRPC); //new PeerBuilderTracker(peer); nodeBehindNat.startSetupRelay(new FutureRelay()); diff --git a/src/test/java/io/bitsquare/msg/UtilsDHT2.java b/src/test/java/io/bitsquare/msg/UtilsDHT2.java index d78c8e07d8..c0b23f6e41 100644 --- a/src/test/java/io/bitsquare/msg/UtilsDHT2.java +++ b/src/test/java/io/bitsquare/msg/UtilsDHT2.java @@ -48,7 +48,7 @@ import net.tomp2p.peers.PeerSocketAddress; public class UtilsDHT2 { /** - * Used to make the testcases predictable. Used as an input for {@link java.util.Random}. + * Used to make the testcases predictable. Used as an input for {@link Random}. */ public static final long THE_ANSWER = 42L; @@ -83,8 +83,9 @@ public class UtilsDHT2 { return createAddress(new Number160(id), "127.0.0.1", 8005, 8006, false, false); } - public static PeerAddress createAddress(Number160 idSender, String inetSender, int tcpPortSender, int udpPortSender, - boolean firewallUDP, boolean firewallTCP) throws UnknownHostException { + public static PeerAddress createAddress(Number160 idSender, String inetSender, int tcpPortSender, + int udpPortSender, boolean firewallUDP, + boolean firewallTCP) throws UnknownHostException { InetAddress inetSend = InetAddress.getByName(inetSender); PeerSocketAddress peerSocketAddress = new PeerSocketAddress(inetSend, tcpPortSender, udpPortSender); PeerAddress n1 = new PeerAddress(idSender, peerSocketAddress, firewallTCP, firewallUDP, false, @@ -93,9 +94,11 @@ public class UtilsDHT2 { } public static Message createDummyMessage(Number160 idSender, String inetSender, int tcpPortSendor, - int udpPortSender, Number160 idRecipien, String inetRecipient, - int tcpPortRecipient, int udpPortRecipient, byte command, Type type, - boolean firewallUDP, boolean firewallTCP) throws UnknownHostException { + int udpPortSender, Number160 idRecipien, String inetRecipient, + int tcpPortRecipient, + int udpPortRecipient, byte command, Type type, boolean firewallUDP, + boolean firewallTCP) + throws UnknownHostException { Message message = new Message(); PeerAddress n1 = createAddress(idSender, inetSender, tcpPortSendor, udpPortSender, firewallUDP, firewallTCP); @@ -122,18 +125,22 @@ public class UtilsDHT2 { * Creates peers for testing. The first peer (peer[0]) will be used as the master. This means that shutting down * peer[0] will shut down all other peers * - * @param nrOfPeers The number of peers to create including the master - * @param rnd The random object to create random peer IDs - * @param port The port where the master peer will listen to + * @param nrOfPeers + * The number of peers to create including the master + * @param rnd + * The random object to create random peer IDs + * @param port + * The port where the master peer will listen to * @return All the peers, with the master peer at position 0 -> peer[0] - * @throws Exception If the creation of nodes fail. + * @throws Exception + * If the creation of nodes fail. */ public static PeerDHT[] createNodes(int nrOfPeers, Random rnd, int port, AutomaticFuture automaticFuture, boolean maintenance) throws Exception { if (nrOfPeers < 1) { throw new IllegalArgumentException("Cannot create less than 1 peer"); } - Bindings bindings = new Bindings(); + Bindings bindings = new Bindings();//.addInterface("lo"); PeerDHT[] peers = new PeerDHT[nrOfPeers]; final Peer master; if (automaticFuture != null) { @@ -159,8 +166,7 @@ public class UtilsDHT2 { PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId)); Peer peer = new PeerBuilder(peerId) .masterPeer(master) - .enableMaintenance(maintenance).enableMaintenance(maintenance).peerMap(peerMap) - .externalBindings(bindings).start().addAutomaticFuture(automaticFuture); + .enableMaintenance(maintenance).enableMaintenance(maintenance).peerMap(peerMap).externalBindings(bindings).start().addAutomaticFuture(automaticFuture); peers[i] = new PeerBuilderDHT(peer).start(); } else { @@ -208,12 +214,13 @@ public class UtilsDHT2 { * Perfect routing, where each neighbor has contacted each other. This means that for small number of peers, every * peer knows every other peer. * - * @param peers The peers taking part in the p2p network. + * @param peers + * The peers taking part in the p2p network. */ public static void perfectRouting(PeerDHT... peers) { for (int i = 0; i < peers.length; i++) { for (int j = 0; j < peers.length; j++) - peers[i].peer().peerBean().peerMap().peerFound(peers[j].peer().peerAddress(), null); + peers[i].peer().peerBean().peerMap().peerFound(peers[j].peer().peerAddress(), null, null); } System.err.println("perfect routing done."); } @@ -221,7 +228,7 @@ public class UtilsDHT2 { public static void perfectRoutingIndirect(PeerDHT... peers) { for (int i = 0; i < peers.length; i++) { for (int j = 0; j < peers.length; j++) - peers[i].peerBean().peerMap().peerFound(peers[j].peerAddress(), peers[j].peerAddress()); + peers[i].peerBean().peerMap().peerFound(peers[j].peerAddress(), peers[j].peerAddress(), null); } System.err.println("perfect routing done."); }