Mise à jour de GitLab prévue ce dimanche 25 octobre 2020 à partir de 9h00 CEST | GitLab upgrade planned this Sunday 25rd of October 2020 from 9:00 AM CEST

Commit d57b7a29 authored by Éloïs's avatar Éloïs

[enh] add basic wotb functions and tests

parent 8f573950
native/target
native/index.node
native/artifacts.json
**/*~
**/node_modules
**/.DS_Store
"use strict";
const addon = require('../native');
const path = require('path');
module.exports = {
/*newFileInstance: (filePath) => {
const instance = Object.create(WotB)
if (process.platform == 'win32') {
let bufferedPath = new Buffer(filePath,'ascii');
instance.init(wotb.newFileInstanceWin32(bufferedPath, bufferedPath.length))
} else {
instance.init(wotb.new_file_instance(filePath));
}
instance.setFilePath(filePath)
return instance
},*/
newMemoryInstance: (sigStock) => {
const instance = Object.create(WotB)
const id = addon.new_memory_instance(sigStock);
instance.init(id)
return instance
},
};
const WotB = {
instanceID: -1,
filePath: "",
init: function(instanceId){
this.instanceID = instanceId
},
/**
* Eventually has a file path if it is a file instance.
* @param filePath
*/
setFilePath: function(filePath) {
this.filePath = filePath
},
memCopy: function() {
const copy = Object.create(WotB)
copy.instanceID = addon.mem_copy(this.instanceID);
return copy;
},
getMaxCert: function() {
return addon.get_max_links(this.instanceID);
},
getWoTSize: function() {
return addon.get_wot_size(this.instanceID);
},
isEnabled: function(nodeId) {
return addon.is_enabled(this.instanceID, nodeId);
},
getEnabled: function() {
var wot_size = addon.get_wot_size(this.instanceID);
var enabled_array = new Array();
for (let i = 0; i < wot_size; i++) {
if (addon.is_enabled(this.instanceID, i)) {
enabled_array.push(i);
}
}
return enabled_array;
},
getDisabled: function() {
var wot_size = addon.get_wot_size(this.instanceID);
var enabled_array = new Array();
for (let i = 0; i < wot_size; i++) {
if (!addon.is_enabled(this.instanceID, i)) {
enabled_array.push(i);
}
}
return enabled_array;
},
existsLink: function(source, target) {
return addon.exist_link(this.instanceID, source, target);
},
setMaxCert: function(maxCert) {
return addon.set_max_links(this.instanceID, maxCert);
},
addNode: function() {
return addon.add_node(this.instanceID);
},
removeNode: function() {
return addon.rem_node(this.instanceID);
},
setEnabled: function(is_enabled, nodeId) {
return addon.set_enabled(this.instanceID, is_enabled, nodeId);
},
addLink: function(source, target) {
return addon.add_link(this.instanceID, source, target);
},
removeLink: function(source, target) {
return addon.rem_link(this.instanceID, source, target);
},
isOutdistanced: function(node, sentry_requirement, step_max, x_percent) {
var distance_result = addon.compute_distance(this.instanceID, node, sentry_requirement, step_max, x_percent);
return distance_result.outdistanced;
},
clear: function() {
return addon.remove_wot(this.instanceID);
}
}
\ No newline at end of file
This diff is collapsed.
[package]
name = "wotb-rs"
version = "0.1.0"
authors = ["librelois <elois@ifee.fr>"]
license = "AGPL-3.0"
build = "build.rs"
[lib]
name = "wotb_rs"
crate-type = ["dylib"]
[build-dependencies]
neon-build = "0.1.22"
[dependencies]
neon = "0.1.22"
num_cpus = "1.8.0"
duniter-wotb = "0.7.1"
extern crate neon_build;
fn main() {
neon_build::setup(); // must be called in build.rs
// add project-specific build logic here...
}
This diff is collapsed.
This diff is collapsed.
{
"name": "wotb-rs",
"version": "0.1.0",
"description": "Makes Web of Trust computations for the Duniter project.",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "https://git.duniter.org/nodes/typescript/wotb-rust"
},
"author": "librelois <elois@ifee.fr>",
"license": "AGPL-3.0",
"engines": {
"node": ">=9.4.0",
"npm": ">=5.6.0"
},
"dependencies": {
"neon-cli": "^0.1.22"
},
"devDependencies": {
"aws-sdk": "2.2.43",
"mocha": "2.2.5",
"should": "8.1.1"
},
"scripts": {
"test": "node \"node_modules/mocha/bin/mocha\" tests/",
"install": "neon build"
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment