This repository has been archived by the owner on Sep 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from boplish/chord
refs #4 Add Chord implementation
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
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,35 @@ | ||
var Chord = function() { | ||
// TODO: implement, initialize node ID | ||
}; | ||
|
||
/** | ||
* join the DHT by using the 'bootstrap' DataChannel | ||
* | ||
* @param bootstrap DataChannel connection of bootstrap host | ||
*/ | ||
Chord.prototype.join = function(bootstrap) { | ||
// TODO: implement | ||
}; | ||
|
||
/** | ||
* Store 'value' under 'key' in the DHT | ||
* | ||
* @param key | ||
* @param value | ||
*/ | ||
Chord.prototype.put = function(key, value) { | ||
// TODO: implement | ||
}; | ||
|
||
Chord.prototype.remove = function(key) { | ||
// TODO: implement | ||
}; | ||
|
||
Chord.prototype.get = function(key) { | ||
// TODO: implement | ||
}; | ||
|
||
|
||
if (typeof(module) !== 'undefined') { | ||
module.exports = Chord; | ||
} |
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,30 @@ | ||
var Node = function(id, dc) { | ||
if (!(this instanceof Node)) { | ||
return new Node(); | ||
} | ||
|
||
this.finger_table = []; | ||
|
||
return this; | ||
|
||
}; | ||
|
||
Node.prototype = { | ||
|
||
message_types: { | ||
GET_SUCCESSOR: 0, | ||
FIND_SUCCESSOR: 1, | ||
FIND_PREDECESSOR: 2, | ||
FIND_CLOSEST_PRECEDING_FINGER: 3, | ||
}, | ||
|
||
find_successor: function (id) { | ||
}, | ||
|
||
|
||
}; | ||
|
||
|
||
if (typeof(module) !== 'undefined') { | ||
module.exports = Node; | ||
} |