issue #4: prevent connections to self, select random nodes to connect to

This commit is contained in:
2015-06-13 17:37:55 +02:00
parent bd5bf76904
commit ed0d1c2911
4 changed files with 21 additions and 4 deletions

View File

@ -37,7 +37,7 @@ public class JdbcNodeRegistry extends JdbcHelper implements NodeRegistry {
List<NetworkAddress> result = new LinkedList<>();
try (Connection connection = config.getConnection()) {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM Node WHERE stream IN (" + join(streams) + ") LIMIT " + limit);
ResultSet rs = stmt.executeQuery("SELECT * FROM Node WHERE stream IN (" + join(streams) + ") ORDER BY RANDOM() LIMIT " + limit);
while (rs.next()) {
result.add(new NetworkAddress.Builder()
.ipv6(rs.getBytes("ip"))