git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit d3536785221ae80c8fa989fe366b449986ee1169

paramitize DFS check condition

Signed-off-by: wanderer <mjbecze@gmail.com>
wanderer committed on 8/22/2017, 7:40:01 PM
Parent: ded42bab9d3ec663f4308b94ae68a926196845cb

Files changed

dfsChecker.jschanged
index.jschanged
dfsChecker.jsView
@@ -6,9 +6,9 @@
66 * @param {object} state - the state containing all of the containers to search
77 * @param {string} root - the root id
88 * @param {Set} nodes - a set of nodes to start searching from
99 */
10-module.exports = async function DFSchecker (tree, root, nodes) {
10+module.exports = async function DFSchecker (tree, nodes, checkFn) {
1111 const checkedNodesSet = new Set()
1212 let hasRootSet = new Set()
1313 const promises = []
1414
@@ -53,9 +53,9 @@
5353 // mark the node 'checked'
5454 checkedNodes.add(id)
5555
5656 // check to see if we are at the root
57- if (id === root) {
57+ if (checkFn(id)) {
5858 hasRootSet = checkedNodes
5959 return
6060 }
6161
index.jsView
@@ -182,13 +182,14 @@
182182 */
183183 async createStateRoot (ticks) {
184184 await this.scheduler.wait(ticks)
185185
186- const unlinked = await DFSchecker(this.tree, this.ROOT_ID, this._nodesToCheck)
186+ const unlinked = await DFSchecker(this.tree, this._nodesToCheck, (id) => {
187+ return this.ROOT_ID === id
188+ })
187189 for (const id of unlinked) {
188190 await this.tree.delete(id)
189191 }
190-
191192 return this.graph.flush(this.state)
192193 }
193194
194195 /**

Built with git-ssb-web