Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wotb-rs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
typescript
wotb-rs
Commits
9d5d804d
Commit
9d5d804d
authored
7 years ago
by
nanocryk
Browse files
Options
Downloads
Patches
Plain Diff
tests
parent
645b16e5
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+2
-0
2 additions, 0 deletions
.gitignore
lib/index.ts
+7
-3
7 additions, 3 deletions
lib/index.ts
native/src/lib.rs
+14
-5
14 additions, 5 deletions
native/src/lib.rs
tests/test.js
+1
-1
1 addition, 1 deletion
tests/test.js
with
24 additions
and
9 deletions
.gitignore
+
2
−
0
View file @
9d5d804d
...
...
@@ -10,3 +10,5 @@ native/artifacts.json
*.wot
build/
\.vscode/
This diff is collapsed.
Click to expand it.
lib/index.ts
+
7
−
3
View file @
9d5d804d
...
...
@@ -114,7 +114,7 @@ export class MemoryWebOfTrust implements WebOfTrust {
}
resetWoT
():
void
{
this
.
wot
=
new
NativeWebOfTrust
(
this
.
wot
.
getMaxCert
())
}
}
...
...
@@ -123,8 +123,10 @@ export class AtomicFileWebOfTrust implements WebOfTrust {
filePath
:
String
;
constructor
(
path
:
String
)
{
console
.
log
(
"
before
"
)
this
.
wot
=
new
NativeWebOfTrust
(
path
);
this
.
filePath
=
path
;
console
.
log
(
"
after
"
)
}
toFile
(
path
:
String
):
Boolean
{
...
...
@@ -217,6 +219,8 @@ export class AtomicFileWebOfTrust implements WebOfTrust {
}
resetWoT
():
void
{
this
.
wot
=
new
NativeWebOfTrust
(
this
.
wot
.
getMaxCert
())
}
}
var
test
=
new
AtomicFileWebOfTrust
(
"
test.wot
"
);
\ No newline at end of file
This diff is collapsed.
Click to expand it.
native/src/lib.rs
+
14
−
5
View file @
9d5d804d
...
...
@@ -4,7 +4,10 @@
extern
crate
neon
;
extern
crate
duniter_rs_wotb
;
use
neon
::
js
::{
Value
,
JsInteger
,
JsString
,
JsBoolean
,
JsFunction
,
JsArray
,
JsNumber
,
JsObject
,
Object
};
use
std
::
path
::
Path
;
use
neon
::
js
::{
Value
,
JsInteger
,
JsString
,
JsBoolean
,
JsFunction
,
JsArray
,
JsNumber
,
JsObject
,
Object
};
use
neon
::
js
::
class
::{
Class
,
JsClass
};
use
neon
::
mem
::
Handle
;
use
neon
::
vm
::{
Throw
,
Lock
};
...
...
@@ -29,10 +32,16 @@ declare_types! {
}
else
if
let
Some
(
path
)
=
arg0
.downcast
::
<
JsString
>
()
{
let
path
=
path
.value
();
if
!
Path
::
new
(
&
path
)
.exists
()
{
let
wot
=
WebOfTrust
::
new
(
0
);
wot
.to_file
(
&
path
);
Ok
(
wot
)
}
else
{
match
WebOfTrust
::
from_file
(
path
.as_str
())
{
Some
(
wot
)
=>
Ok
(
wot
),
None
=>
Err
(
Throw
),
}
}
}
else
{
Err
(
Throw
)
}
...
...
This diff is collapsed.
Click to expand it.
tests/test.js
+
1
−
1
View file @
9d5d804d
...
...
@@ -6,7 +6,7 @@ var assert = require('assert');
var
path
=
require
(
'
path
'
);
var
fs
=
require
(
'
fs
'
);
const
FILE
=
path
.
join
(
__dirname
,
'
wot.
bin
'
);
const
FILE
=
path
.
join
(
__dirname
,
'
wot.
wot
'
);
const
X_PERCENT
=
1.0
;
const
_100_PERCENT
=
1.0
;
const
MAX_DISTANCE_1
=
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment