fixed a error in the leave-method, where nodes would get the same new neighbor twice
This commit is contained in:
parent
269c1e4e1b
commit
8771f1ea04
@ -120,8 +120,8 @@ public class Node {
|
||||
|
||||
for (int i = 0; i < neighbors.size(); i++) {
|
||||
|
||||
if (neighbors.size() > 1) {
|
||||
try {
|
||||
try {
|
||||
if (neighbors.size() > 2) {
|
||||
if (i == 0) {
|
||||
|
||||
putAddrInBuf(buf, neighbors.get(1));
|
||||
@ -146,9 +146,13 @@ public class Node {
|
||||
putAddrInBuf(buf, neighbors.get(i + 1));
|
||||
channel.send(buf, neighbors.get(i));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
} else if (neighbors.size() == 2) {
|
||||
putAddrInBuf(buf, neighbors.get(Math.abs(i - 1)));
|
||||
channel.send(buf, neighbors.get(i));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
buf.clear();
|
||||
@ -237,11 +241,10 @@ public class Node {
|
||||
break;
|
||||
|
||||
case MessageType.NEW_NEIGHBOR_IPV4:
|
||||
LOGGER.info(name
|
||||
+ " received new IPv6 neighbor"
|
||||
LOGGER.info(name + " received new IPv6 neighbor"
|
||||
+ receivedFrom.toString() + ": "
|
||||
+ new String(buf.array()));
|
||||
|
||||
|
||||
byte[] byte_addr = new byte[7];
|
||||
|
||||
// Read 4 Bytes and 1 Int
|
||||
@ -259,8 +262,6 @@ public class Node {
|
||||
// check, if we have the neighbor already.
|
||||
if (!hasNeighbor(new_neighbor)) {
|
||||
neighbors.add(new_neighbor);
|
||||
LOGGER.info(name + " adds new neighbor: "
|
||||
+ new String(buf.array()));
|
||||
}
|
||||
|
||||
// TODO: send PING to new neighbor and expect wait
|
||||
@ -295,8 +296,6 @@ public class Node {
|
||||
// check, if we have the neighbor already.
|
||||
if (!hasNeighbor(new_neighbor)) {
|
||||
neighbors.add(new_neighbor);
|
||||
LOGGER.info(name + " adds new neighbor: "
|
||||
+ new String(buf.array()));
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user