Decided for a different arch: Each project has it's own kvstore db, instead of one global db - this means that every project developer has control over their dependencies

main
CSDUMMI 2022-03-23 18:33:58 +01:00
rodzic 243c363f3b
commit eb1739dc4c
2 zmienionych plików z 33 dodań i 22 usunięć

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -1,36 +1,34 @@
const Graph = require("graph-data-structure");
class GraphIndex {
class Graph {
/**
* Wrapper around the graph-data-structure
* that parses the oplog to create a corresponding
* Graph.
* Wrapper around the graph-data-structure.
*/
constructor() {
this._graph = Graph();
constructor(orbitdb) {
this._graph = Graph()
this._projects = {}
this._orbitdb = orbitdb
}
/**
* Each project points to a database
* containing all the information about a project.
*/
addProject(cid) {
this._graph.addNode(cid)
}
async addProject(project) {
if(this._project[project.address.toString()]) {
return false
}
/**
* A depedency is a directed edg
* from the project dependent on another project to that project.
*
* If project A dependes on B, an edge from A to B is added.
*
* The weight is in the interval 0,1 and indicates the probability
* that an error/bug/problem in the dependency causes an error/bug/problem
* in the dependent project.
*/
addDependency(dependent, dependency, weight) {
this._graph.addEdge(dependent, depedency, weight)
this._graph.addNode(project.address.toString())
this._projects[project.address.toString()] = project
for(let dependency of Object.keys(project.all)) {
this.addProject(await this._orbitdb.open(dependency))
this._graph.addEdge(project.address.toString(), dependency, project.get(dependency))
}
return true
}
/**
@ -40,5 +38,18 @@ class GraphIndex {
return this._graph.nodes()
}
depedencyBetween
/**
* @returns {number} indicating how important a depedency for a dependent project to
* function properly.
*
* Calculated by taking all paths from dependent to dependency project,
* multiplying the weights on each path and summing those products.
*/
depedencyBetween(dependent, dependency) {
const paths = calculateAllPaths(dependent, depedency)
}
calculateAllPaths(start, end) {
let adjacents = this._graph.adjacent(start)
}
}