Skip to content

Instantly share code, notes, and snippets.

@arriqaaq
Last active Sep 12, 2018
Embed
What would you like to do?
func (n *Node) join(joinNode *internal.Node) error {
// First check if node already present in the circle
// Join this node to the same chord ring as parent
var foo *internal.Node
// // Ask if our id already exists on the ring.
if joinNode != nil {
remoteNode, err := n.findSuccessorRPC(joinNode, n.Id)
if err != nil {
return err
}
if isEqual(remoteNode.Id, n.Id) {
return ERR_NODE_EXISTS
}
foo = joinNode
} else {
foo = n.Node
}
succ, err := n.findSuccessorRPC(foo, n.Id)
if err != nil {
return err
}
n.succMtx.Lock()
n.successor = succ
n.succMtx.Unlock()
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment