Skip to content
Snippets Groups Projects
Commit 1fc75139 authored by Éloïs's avatar Éloïs
Browse files

[enh] change addon path to absolute and autorize node 8

parent 126a83a2
No related branches found
No related tags found
No related merge requests found
Pipeline #
"use strict"; "use strict";
const addon = require('../native');
const path = require('path'); const path = require('path');
const binding_path = path.resolve(path.join(__dirname,'../native'));
const binding = require(binding_path);
module.exports = { module.exports = {
...@@ -9,9 +10,9 @@ module.exports = { ...@@ -9,9 +10,9 @@ module.exports = {
const instance = Object.create(WotB) const instance = Object.create(WotB)
if (process.platform == 'win32') { if (process.platform == 'win32') {
let bufferedPath = new Buffer(filePath,'ascii'); let bufferedPath = new Buffer(filePath,'ascii');
instance.init(addon.new_file_instance_win_32(bufferedPath, bufferedPath.length, sigStock)) instance.init(binding.new_file_instance_win_32(bufferedPath, bufferedPath.length, sigStock))
} else { } else {
instance.init(addon.new_file_instance(filePath, sigStock)); instance.init(binding.new_file_instance(filePath, sigStock));
} }
instance.setFilePath(filePath) instance.setFilePath(filePath)
return instance return instance
...@@ -19,7 +20,7 @@ module.exports = { ...@@ -19,7 +20,7 @@ module.exports = {
newMemoryInstance: (sigStock) => { newMemoryInstance: (sigStock) => {
const instance = Object.create(WotB) const instance = Object.create(WotB)
const id = addon.new_memory_instance(sigStock); const id = binding.new_memory_instance(sigStock);
instance.init(id) instance.init(id)
return instance return instance
}, },
...@@ -45,53 +46,53 @@ const WotB = { ...@@ -45,53 +46,53 @@ const WotB = {
}, },
write: function() { write: function() {
return addon.write_instance_in_file(this.instanceID, this.filePath); return binding.write_instance_in_file(this.instanceID, this.filePath);
}, },
memCopy: function() { memCopy: function() {
const copy = Object.create(WotB) const copy = Object.create(WotB)
copy.instanceID = addon.mem_copy(this.instanceID); copy.instanceID = binding.mem_copy(this.instanceID);
return copy; return copy;
}, },
getMaxCert: function() { getMaxCert: function() {
return addon.get_max_links(this.instanceID); return binding.get_max_links(this.instanceID);
}, },
getWoTSize: function() { getWoTSize: function() {
return addon.get_wot_size(this.instanceID); return binding.get_wot_size(this.instanceID);
}, },
isEnabled: function(nodeId) { isEnabled: function(nodeId) {
return addon.is_enabled(this.instanceID, nodeId); return binding.is_enabled(this.instanceID, nodeId);
}, },
getEnabled: function() { getEnabled: function() {
return addon.get_enabled(this.instanceID); return binding.get_enabled(this.instanceID);
}, },
getDisabled: function() { getDisabled: function() {
return addon.get_disabled(this.instanceID); return binding.get_disabled(this.instanceID);
}, },
getSentries: function(sentry_requirement) { getSentries: function(sentry_requirement) {
return addon.get_sentries(this.instanceID, sentry_requirement); return binding.get_sentries(this.instanceID, sentry_requirement);
}, },
getNonSentries: function(sentry_requirement) { getNonSentries: function(sentry_requirement) {
return addon.get_non_sentries(this.instanceID, sentry_requirement); return binding.get_non_sentries(this.instanceID, sentry_requirement);
}, },
existsLink: function(source, target) { existsLink: function(source, target) {
return addon.exist_link(this.instanceID, source, target); return binding.exist_link(this.instanceID, source, target);
}, },
setMaxCert: function(maxCert) { setMaxCert: function(maxCert) {
return addon.set_max_links(this.instanceID, maxCert); return binding.set_max_links(this.instanceID, maxCert);
}, },
addNode: function() { addNode: function() {
var result = addon.add_node(this.instanceID); var result = binding.add_node(this.instanceID);
if (this.filePath.length > 0) { if (this.filePath.length > 0) {
this.write(); this.write();
} }
...@@ -99,7 +100,7 @@ const WotB = { ...@@ -99,7 +100,7 @@ const WotB = {
}, },
removeNode: function() { removeNode: function() {
var result = addon.rem_node(this.instanceID); var result = binding.rem_node(this.instanceID);
if (this.filePath.length > 0) { if (this.filePath.length > 0) {
this.write(); this.write();
} }
...@@ -107,7 +108,7 @@ const WotB = { ...@@ -107,7 +108,7 @@ const WotB = {
}, },
setEnabled: function(is_enabled, nodeId) { setEnabled: function(is_enabled, nodeId) {
var result = addon.set_enabled(this.instanceID, is_enabled, nodeId); var result = binding.set_enabled(this.instanceID, is_enabled, nodeId);
if (this.filePath.length > 0) { if (this.filePath.length > 0) {
this.write(); this.write();
} }
...@@ -115,7 +116,7 @@ const WotB = { ...@@ -115,7 +116,7 @@ const WotB = {
}, },
addLink: function(source, target) { addLink: function(source, target) {
var result = addon.add_link(this.instanceID, source, target); var result = binding.add_link(this.instanceID, source, target);
if (this.filePath.length > 0) { if (this.filePath.length > 0) {
this.write(); this.write();
} }
...@@ -123,7 +124,7 @@ const WotB = { ...@@ -123,7 +124,7 @@ const WotB = {
}, },
removeLink: function(source, target) { removeLink: function(source, target) {
var result = addon.rem_link(this.instanceID, source, target); var result = binding.rem_link(this.instanceID, source, target);
if (this.filePath.length > 0) { if (this.filePath.length > 0) {
this.write(); this.write();
} }
...@@ -131,12 +132,12 @@ const WotB = { ...@@ -131,12 +132,12 @@ const WotB = {
}, },
isOutdistanced: function(node, sentry_requirement, step_max, x_percent) { isOutdistanced: function(node, sentry_requirement, step_max, x_percent) {
var distance_result = addon.compute_distance(this.instanceID, node, sentry_requirement, step_max, x_percent); var distance_result = binding.compute_distance(this.instanceID, node, sentry_requirement, step_max, x_percent);
return distance_result.outdistanced; return distance_result.outdistanced;
}, },
detailedDistance: function(node, sentry_requirement, step_max, x_percent) { detailedDistance: function(node, sentry_requirement, step_max, x_percent) {
var distance_result = addon.compute_distance(this.instanceID, node, sentry_requirement, step_max, x_percent); var distance_result = binding.compute_distance(this.instanceID, node, sentry_requirement, step_max, x_percent);
return { return {
nbReached: distance_result.reached, nbReached: distance_result.reached,
nbSuccess: distance_result.success, nbSuccess: distance_result.success,
...@@ -146,21 +147,21 @@ const WotB = { ...@@ -146,21 +147,21 @@ const WotB = {
}, },
detailedDistanceV2: function(node, sentry_requirement, step_max, x_percent) { detailedDistanceV2: function(node, sentry_requirement, step_max, x_percent) {
return addon.compute_distance(this.instanceID, node, sentry_requirement, step_max, x_percent); return binding.compute_distance(this.instanceID, node, sentry_requirement, step_max, x_percent);
}, },
getPaths: function(from, to, step_max) { getPaths: function(from, to, step_max) {
return addon.find_paths(this.instanceID, from, to, step_max); return binding.find_paths(this.instanceID, from, to, step_max);
}, },
clear: function() { clear: function() {
return addon.remove_wot(this.instanceID); return binding.remove_wot(this.instanceID);
}, },
resetWoT: function() { resetWoT: function() {
var sigStock = addon.getMaxCert(this.instanceID); var sigStock = binding.getMaxCert(this.instanceID);
addon.remove_wot(this.instanceID); binding.remove_wot(this.instanceID);
this.instanceID = addon.new_memory_instance(sigStock); this.instanceID = binding.new_memory_instance(sigStock);
if (filePath.length > 0) { if (filePath.length > 0) {
this.write(); this.write();
} }
......
{ {
"name": "wotb-rs", "name": "wotb-rs",
"version": "0.1.1", "version": "0.1.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
......
{ {
"name": "wotb-rs", "name": "wotb-rs",
"version": "0.1.1", "version": "0.1.2",
"description": "Makes Web of Trust computations for the Duniter project.", "description": "Makes Web of Trust computations for the Duniter project.",
"main": "lib/index.js", "main": "lib/index.js",
"repository": { "repository": {
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"author": "librelois <elois@ifee.fr>", "author": "librelois <elois@ifee.fr>",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"engines": { "engines": {
"node": ">=9.4.0", "node": ">=8.11.1",
"npm": ">=5.6.0" "npm": ">=5.6.0"
}, },
"dependencies": { "dependencies": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment