-
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.
- Loading branch information
1 parent
29b0583
commit 7503d93
Showing
3 changed files
with
63 additions
and
10 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Has the responsibility to gather and report number of shuffles between encounters of other nodes. This data | ||
* can possibly be used to measure network size. | ||
*/ | ||
class EncounterIntervalProbe { | ||
get node() { | ||
return this._node; | ||
} | ||
|
||
get sampleSize() { | ||
return this._sampleSize; | ||
} | ||
|
||
get encounterCounts() { | ||
return this._encounterCounts; | ||
} | ||
/** | ||
* | ||
* @param sampleSize number of nodes to check encounters for. | ||
* @param encounterCounts number of encounters to average and report at once | ||
*/ | ||
constructor(node,sampleSize,encounterCounts){ | ||
this._node = node; | ||
this._sampleSize = sampleSize; | ||
this._encounterCounts = encounterCounts; | ||
this.samples= [] | ||
this._gatherData(); | ||
this.currentIndex= 0; | ||
} | ||
|
||
_gatherData(){ | ||
this._node.__cyclonNode.on("neighbours_updated", ()=> { | ||
if (this.currentIndex===0){ | ||
this._initializeSamples(); | ||
}else{ | ||
this._updateSamples(); | ||
this._checkFinishCriteria(); | ||
} | ||
this.currentIndex++; | ||
}); | ||
} | ||
_checkFinishCriteria(){ | ||
|
||
} | ||
|
||
_updateSamples(){ | ||
|
||
} | ||
|
||
_initializeSamples(){ | ||
let neighbors = this._node.getRandomSamplePointers(); | ||
let size = Math.min(neighbors.length, this._sampleSize); | ||
for (let i=0;i<size;i++){ | ||
let sample = {id: neighbors[i].id,encounters:[]}; | ||
this.samples.push(sample); | ||
} | ||
}; | ||
|
||
} |