0

我在这里查看和弦算法的伪代码:

// create a new Chord ring.
n.create()
    predecessor := nil
    successor := n

// join a Chord ring containing node n'.
n.join(n')
    predecessor := nil
    successor := n'.find_successor(n)

// called periodically. n asks the successor
// about its predecessor, verifies if n's immediate
// successor is consistent, and tells the successor about n
n.stabilize()
    x = successor.predecessor
    if x ∈ (n, successor) then
        successor := x
    successor.notify(n)

// n' thinks it might be our predecessor.
n.notify(n')
    if predecessor is nil or n'∈(predecessor, n) then
        predecessor := n'

// called periodically. refreshes finger table entries.
// next stores the index of the finger to fix
n.fix_fingers()
    next := next + 1
    if next > m then
        next := 1
    finger[next] := find_successor(n+{\displaystyle 2^{next-1}}2^{next-1});

// called periodically. checks whether predecessor has failed.
n.check_predecessor()
    if predecessor has failed then
        predecessor := nil

我正在努力理解它。我的具体问题是:该predecessor字段究竟什么时候会是非空的?

考虑一个节点 id 1 加入的情况。它的后继是1,前任是nil。

现在说有 10 个连接的节点。它的后继是1,前任是零。

稳定例程取决于前一个节点是非零的,在这种情况下它不是两个节点。

那么算法在这一点上是如何进行的呢?

4

0 回答 0