The implementer of "jchord" seems to agree with you, since he adds the following code to findSuccessor
:
if (this == successor) {
return this;
}
But there seems to be a more elegant solution with is closer to the pseudo code. When checking if an ID is in the interval (n, successor] (left excluded, right included), make that check cyclic. jDHTUQ seems to do it like this (Starting at line 75. Warning: Really ugly code):
IMHO performing the interval check in a cyclic way seems to be the right thing to do. The paper you linked says (on page 4):
The notation (a; b] denotes the segment of the Chord ring obtained by moving clockwise from (but not including) a until reaching (and including) b.
In case of a single node, you would check if
id is.in (n, n]
which should yield true
since the id is within the ring that starts right after n
and ends with n
.