This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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