diff --git a/lib/index.js b/lib/index.js index baa4804451b566191384009f5212dbcbe9f8800d..6de2283e675f720373fd0c066458c04924f7d237 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 fc0e42bfc1e579b68c1730b22ebbc3d37dbc74b6..a09a07bb7689f653cf0f16c0efbc68255cee3d1e 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()) + } } }