@SuppressWarnings("FieldAccessNotGuarded") // only called when inactives is accessed, and lock is held then. @Override public int compare(PeerAddress a, PeerAddress b) { checkState(lock.isHeldByCurrentThread()); int result = backoffMap.get(a).compareTo(backoffMap.get(b)); // Sort by port if otherwise equals - for testing if (result == 0) result = Ints.compare(a.getPort(), b.getPort()); return result; } });
@SuppressWarnings("FieldAccessNotGuarded") // only called when inactives is accessed, and lock is held then. @Override public int compare(PeerAddress a, PeerAddress b) { checkState(lock.isHeldByCurrentThread()); int result = backoffMap.get(a).compareTo(backoffMap.get(b)); // Sort by port if otherwise equals - for testing if (result == 0) result = Ints.compare(a.getPort(), b.getPort()); return result; } });
@SuppressWarnings("FieldAccessNotGuarded") // only called when inactives is accessed, and lock is held then. @Override public int compare(PeerAddress a, PeerAddress b) { checkState(lock.isHeldByCurrentThread()); int result = backoffMap.get(a).compareTo(backoffMap.get(b)); // Sort by port if otherwise equals - for testing if (result == 0) result = Ints.compare(a.getPort(), b.getPort()); return result; } });
@SuppressWarnings("FieldAccessNotGuarded") // only called when inactives is accessed, and lock is held then. @Override public int compare(PeerAddress a, PeerAddress b) { checkState(lock.isHeldByCurrentThread()); int result = backoffMap.get(a).compareTo(backoffMap.get(b)); // Sort by port if otherwise equals - for testing if (result == 0) result = Ints.compare(a.getPort(), b.getPort()); return result; } });
public InetSocketAddress getSocketAddress() { return new InetSocketAddress(getAddr(), getPort()); }
public InetSocketAddress getSocketAddress() { return new InetSocketAddress(getAddr(), getPort()); }
public InetSocketAddress getSocketAddress() { return new InetSocketAddress(getAddr(), getPort()); }
public InetSocketAddress getSocketAddress() { return new InetSocketAddress(getAddr(), getPort()); }
addresses.addAll(Lists.newArrayList(new InetSocketAddress("localhost", 2003))); stopPeerServer(2); assertEquals(2002, disconnectedPeers.take().getAddress().getPort()); // peer died assertEquals(2003, connectedPeers.take().getAddress().getPort()); assertEquals(2001, disconnectedPeers.take().getAddress().getPort()); // peer died assertEquals(2001, disconnectedPeers.take().getAddress().getPort()); assertEquals(2002, disconnectedPeers.take().getAddress().getPort()); assertEquals(2001, disconnectedPeers.take().getAddress().getPort()); assertEquals(2002, disconnectedPeers.take().getAddress().getPort()); assertEquals(2001, disconnectedPeers.take().getAddress().getPort()); jobBlocks.release(1); handleConnectToPeer(2); assertEquals(2002, connectedPeers.take().getAddress().getPort()); assertEquals(2002, disconnectedPeers.take().getAddress().getPort()); // peer died assertEquals(2002, disconnectedPeers.take().getAddress().getPort()); assertEquals(2001, disconnectedPeers.take().getAddress().getPort());
Protos.PeerAddress proto = Protos.PeerAddress.newBuilder() .setIpAddress(ByteString.copyFrom(address.getAddr().getAddress())) .setPort(address.getPort()) .setServices(address.getServices().longValue()) .build();
Protos.PeerAddress proto = Protos.PeerAddress.newBuilder() .setIpAddress(ByteString.copyFrom(address.getAddr().getAddress())) .setPort(address.getPort()) .setServices(address.getServices().longValue()) .build();
@Test public void testAddr() throws Exception { final NetworkParameters params = MainNetParams.get(); MessageSerializer serializer = params.getDefaultSerializer(); // the actual data from https://en.bitcoin.it/wiki/Protocol_specification#addr AddressMessage addressMessage = (AddressMessage) serializer.deserialize(ByteBuffer.wrap(ADDRESS_MESSAGE_BYTES)); assertEquals(1, addressMessage.getAddresses().size()); PeerAddress peerAddress = addressMessage.getAddresses().get(0); assertEquals(8333, peerAddress.getPort()); assertEquals("10.0.0.1", peerAddress.getAddr().getHostAddress()); ByteArrayOutputStream bos = new ByteArrayOutputStream(ADDRESS_MESSAGE_BYTES.length); serializer.serialize(addressMessage, bos); assertEquals(31, addressMessage.getMessageSize()); addressMessage.addAddress(new PeerAddress(params, InetAddress.getLocalHost())); assertEquals(61, addressMessage.getMessageSize()); addressMessage.removeAddress(0); assertEquals(31, addressMessage.getMessageSize()); //this wont be true due to dynamic timestamps. //assertTrue(LazyParseByteCacheTest.arrayContains(bos.toByteArray(), addrMessage)); }
Protos.PeerAddress proto = Protos.PeerAddress.newBuilder() .setIpAddress(ByteString.copyFrom(address.getAddr().getAddress())) .setPort(address.getPort()) .setServices(address.getServices().longValue()) .build();
Protos.PeerAddress proto = Protos.PeerAddress.newBuilder() .setIpAddress(ByteString.copyFrom(address.getAddr().getAddress())) .setPort(address.getPort()) .setServices(address.getServices().longValue()) .build();
Protos.PeerAddress proto = Protos.PeerAddress.newBuilder() .setIpAddress(ByteString.copyFrom(address.getAddr().getAddress())) .setPort(address.getPort()) .setServices(address.getServices().longValue()) .build();
Protos.PeerAddress proto = Protos.PeerAddress.newBuilder() .setIpAddress(ByteString.copyFrom(address.getAddr().getAddress())) .setPort(address.getPort()) .setServices(address.getServices().longValue()) .build();