如何解决和弦算法:前任究竟何时变为非零?
我正在查看和弦算法 here 的伪代码:
// 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,前驱为nil。
稳定例程取决于非 nil 的前驱,在这种情况下它不是两个节点。
那么算法在这一点上是如何进行的?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。