-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/find successor #33
Open
Khatwani13
wants to merge
11
commits into
project1-master
Choose a base branch
from
feature/findSuccessor
base: project1-master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
52c7a51
Merge branch 'project1-master' of https://github.com/bama4/Projects i…
mohitkhatwani aedec6f
Merge branch 'project1-master' of https://github.com/bama4/Projects i…
mohitkhatwani 7311d11
Merge branch 'project1-master' of https://github.com/bama4/Projects i…
mohitkhatwani b9ba3dc
Merge branch 'project1-master' of https://github.com/bama4/Projects i…
mohitkhatwani 9e4f9d8
added findSuccessor module
mohitkhatwani 6d7f000
Added findSucc
mohitkhatwani fd5320f
Changed message_defs to string
mohitkhatwani ca1866c
Changed All id's to int64
mohitkhatwani a20494b
Changed main.go
mohitkhatwani fc5ffc1
Changed for loop start index
mohitkhatwani f2987c9
Changed iteration of fingerTable and func arguments
mohitkhatwani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package findSuccessor | ||
|
||
import ( | ||
nodeDefs "../utils/node_defs" | ||
) | ||
|
||
//FindSuccessor ... This function is used to find successor of node with ID targetID | ||
func FindSuccessor(sponsoringNode *nodeDefs.Node, targetID int64) (successor *nodeDefs.Node) { | ||
if targetID > sponsoringNode.ChannelId && targetID <= sponsoringNode.Successor.ChannelId { | ||
successor = sponsoringNode.Successor | ||
} else { | ||
precedingNode := findClosestPrecedingNode(sponsoringNode, targetID) | ||
successor = FindSuccessor(precedingNode, targetID) | ||
} | ||
return successor | ||
} | ||
|
||
func findClosestPrecedingNode(sponsoringNode *nodeDefs.Node, targetID int64) (precedingNode *nodeDefs.Node) { | ||
|
||
for i := range sponsoringNode.FingerTable { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think based on the pseudocode in the paper, you should find the closest preceding node by starting from the end of the fingertable |
||
if sponsoringNode.FingerTable[int64(i)].ChannelId > sponsoringNode.ChannelId && sponsoringNode.FingerTable[int64(i)].ChannelId < targetID { | ||
precedingNode = sponsoringNode.FingerTable[int64(i)] | ||
} | ||
} | ||
return | ||
} |
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sponsoring node is represented as an int64 (if you look at the join ring function in the code, the *node object is the node that needs a successor...that way you wont have to return a successor object. You will already have the node object that needs a successor, and can assign the correct successor to that node object directly)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I thought passing Node instead of only its ID would be nice because FindSucc needs access to successor of sponsoring node which will be available in its node structure.
If we pass only ID then we will need the information of nodes_in_ring so that we can link that ID with its node and then find the successor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok. I think then that passing the sponsoring node as a node object is fine then here. Do you think though that the node that needs the successor should also be an argument so that you can update its successor once you find it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think by the notes in the HW it says it's only responding to a node ID.. which is then used to lookup the specific node in ring_nodes which can also be used to look up the node's successor/predecessor..etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok. I think that is fine then. respond-to is the node that needs a successor right? The function would just need to be in the main file so that you can use the respond-to id to lookup the node respond-to object to update its successor.