I am currently dealing with the Chord protocol.
For each node there are two functions, findSuccessor
and closestPrecedingNode
which are given as pseudo-code.
findSuccessor
is:
n.findSuccessor(id)
if(id is.in (n, successor])
return successor;
else
n' = closestPrecedingNode(id);
return n'.findSuccessor(id);
closestPrecedingNode
is:
n.closestPrecedingNode(id)
for i = m downto 1
if(finger[i] is.in (n, id))
return finger[i];
return n;
When a node is created, its successor is initially set to the node itself, and its finger table is empty.
Now my question is what happens when there is only one single node, and it is asked for any id except its own id. Then findSuccessor
runs the else
block and calls closestPrecedingNode
. Since the finger table is empty, the node itself is returned to findSuccessor
. Hence n'
is then equal to n
.
Afterwards, findSuccessor
is called on n'
, which is a recursive call to itself.
And then we have an infinite loop ... or am I missing something?
NOTE: Pseudo-code is taken from Chord: A Scalable Peer-to-peer Lookup Protocol for Internet Applications, page 5.