Last active
September 12, 2018 10:44
-
-
Save arriqaaq/745d0f73cae6e9c20bea23cc0f77e961 to your computer and use it in GitHub Desktop.
This file contains hidden or 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