From 8bd6c6ce200136396b574463828ed5332cfad3bf Mon Sep 17 00:00:00 2001 From: Nanocryk <nanocryk@gmail.com> Date: Thu, 9 Nov 2017 11:19:08 +0100 Subject: [PATCH] feature : max certs --- lib/index.js | 18 +++++++++++------- native/src/lib.rs | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/lib/index.js b/lib/index.js index baa4804..6de2283 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2,15 +2,19 @@ let WebOfTrust = require('../native').WebOfTrust; { let wot = new WebOfTrust(3); - console.log(wot.add_node()); - console.log(wot.size()) + console.log(wot.getMaxCert()) + wot.setMaxCert(4); + console.log(wot.getMaxCert()) + console.log(wot.addNode()); + console.log(wot.getWoTSize()) } +console.log("-----") + { let wot = new WebOfTrust("hey.wot"); - - console.log("Hello, world !"); - console.log(wot.add_node()); - console.log(wot.size()); - console.log(wot.to_file("hey.wot")); + console.log(wot.getMaxCert()) + console.log(wot.addNode()); + console.log(wot.getWoTSize()); + console.log(wot.toFile("hey.wot")); } diff --git a/native/src/lib.rs b/native/src/lib.rs index fc0e42b..a09a07b 100644 --- a/native/src/lib.rs +++ b/native/src/lib.rs @@ -247,6 +247,28 @@ declare_types! { None => Err(Throw), } } + + method setMaxCert(call) { + let scope = call.scope; + + let max_cert = try!(try!(call.arguments.require(scope, 0)).check::<JsInteger>()).value() as usize; + + call.arguments.this(scope).grab(|wot| { + wot.max_cert = max_cert; + }); + + Ok(JsObject::new(scope).upcast()) + } + + method getMaxCert(call) { + let scope = call.scope; + + let max_cert = call.arguments.this(scope).grab(|wot| { + wot.max_cert + }); + + Ok(JsInteger::new(scope, max_cert as i32).upcast()) + } } } -- GitLab