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 03193931 authored by Éloïs's avatar Éloïs

Merge branch '2-add-basics-methods-with-neon' into 'master'

Resolve "add basics methods with Neon"

Closes #2

See merge request !1
parents 8f573950 c0d98f1c
Pipeline #1955 passed with stage
in 2 minutes and 31 seconds
native/target
native/index.node
native/artifacts.json
**/*~
**/node_modules
**/.DS_Store
stages:
- build_and_tests
.nvm_env: &nvm_env
tags:
- redshift
image: duniter/duniter-js-rs-ci:v0.0.3
before_script:
- export NVM_DIR="$HOME/.nvm"
- . "$NVM_DIR/nvm.sh"
- export PATH="$HOME/.cargo/bin:$PATH"
- nvm install 9.4.0
- nvm use 9.4.0
build_and_tests:
<<: *nvm_env
stage: build_and_tests
script:
- npm install
- npm test
"use strict";
const addon = require('../native');
const path = require('path');
module.exports = {
newFileInstance: (filePath, sigStock) => {
const instance = Object.create(WotB)
if (process.platform == 'win32') {
let bufferedPath = new Buffer(filePath,'ascii');
instance.init(addon.new_file_instance_win_32(bufferedPath, bufferedPath.length, sigStock))
} else {
instance.init(addon.new_file_instance(filePath, sigStock));
}
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
},
write: function() {
return addon.write_instance_in_file(this.instanceID, this.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() {
return addon.get_enabled(this.instanceID);
},
getDisabled: function() {
return addon.get_disabled(this.instanceID);
},
getSentries: function(sentry_requirement) {
return addon.get_sentries(this.instanceID, sentry_requirement);
},
getNonSentries: function(sentry_requirement) {
return addon.get_non_sentries(this.instanceID, sentry_requirement);
},
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;
},
detailedDistance: function(node, sentry_requirement, step_max, x_percent) {
var distance_result = addon.compute_distance(this.instanceID, node, sentry_requirement, step_max, x_percent);
return {
nbReached: distance_result.reached,
nbSuccess: distance_result.success,
nbSentries: distance_result.sentries,
isOutdistanced: distance_result.outdistanced
};
},
detailedDistanceV2: function(node, sentry_requirement, step_max, x_percent) {
return addon.compute_distance(this.instanceID, node, sentry_requirement, step_max, x_percent);
},
getPaths: function(from, to, step_max) {
return addon.find_paths(this.instanceID, from, to, step_max);
},
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.8.0-a0.5"
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-rs"
},
"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