I am currently dealing with the Chord protocol.
There are two functions for each node: findSuccessor and closestPrecedingNode , which are set as pseudocode.
findSuccessor :
n.findSuccessor(id) if(id is.in (n, successor]) return successor; else n' = closestPrecedingNode(id); return n'.findSuccessor(id);
closestPrecedingNode :
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 installed on the node itself, and its finger table is empty.
Now my question is what happens when there is only one node, and it is asked any identifier except its own id. findSuccessor then starts the else block and calls closestPrecedingNode . Since the finger table is empty, the node itself returns to findSuccessor . Therefore, n' then equals n .
Then findSuccessor is called on n' , which is a recursive call for itself.
And then we have an endless loop ... or am I missing something?
NOTE. The pseudo-code is taken from Chord: A Scalable Peer-to-Peer Search Protocol for Internet Applications , p. 5.
source share