Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dunitrust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
GitLab 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
rust
Dunitrust
Commits
cc3597b4
Commit
cc3597b4
authored
7 years ago
by
nanocryk
Browse files
Options
Downloads
Patches
Plain Diff
[fix] improvements following MR review
parent
955ee8cc
No related branches found
No related tags found
1 merge request
!20
Resolve "Implement Web of Trust in a more "rusty" way"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
wotb/rusty.rs
+17
-25
17 additions, 25 deletions
wotb/rusty.rs
with
17 additions
and
25 deletions
wotb/rusty.rs
+
17
−
25
View file @
cc3597b4
...
@@ -119,7 +119,7 @@ impl WebOfTrust for RustyWebOfTrust {
...
@@ -119,7 +119,7 @@ impl WebOfTrust for RustyWebOfTrust {
.map
(|
_
|
enabled
)
.map
(|
_
|
enabled
)
}
}
/// Get enabled node array.
/// Get enabled node
s
array.
fn
get_enabled
(
&
self
)
->
Vec
<
NodeId
>
{
fn
get_enabled
(
&
self
)
->
Vec
<
NodeId
>
{
self
.nodes
self
.nodes
.par_iter
()
.par_iter
()
...
@@ -129,7 +129,7 @@ impl WebOfTrust for RustyWebOfTrust {
...
@@ -129,7 +129,7 @@ impl WebOfTrust for RustyWebOfTrust {
.collect
()
.collect
()
}
}
/// Get disabled node array.
/// Get disabled node
s
array.
fn
get_disabled
(
&
self
)
->
Vec
<
NodeId
>
{
fn
get_disabled
(
&
self
)
->
Vec
<
NodeId
>
{
self
.nodes
self
.nodes
.par_iter
()
.par_iter
()
...
@@ -270,13 +270,6 @@ impl WebOfTrust for RustyWebOfTrust {
...
@@ -270,13 +270,6 @@ impl WebOfTrust for RustyWebOfTrust {
return
None
;
return
None
;
}
}
let
mut
distance
=
WotDistance
{
sentries
:
0
,
success
:
0
,
reached
:
0
,
outdistanced
:
false
,
};
let
mut
area
=
HashSet
::
new
();
let
mut
area
=
HashSet
::
new
();
area
.insert
(
node
);
area
.insert
(
node
);
let
mut
border
=
HashSet
::
new
();
let
mut
border
=
HashSet
::
new
();
...
@@ -305,13 +298,20 @@ impl WebOfTrust for RustyWebOfTrust {
...
@@ -305,13 +298,20 @@ impl WebOfTrust for RustyWebOfTrust {
area
.extend
(
border
.iter
());
area
.extend
(
border
.iter
());
}
}
let
sentries
=
self
.get_sentries
(
sentry_requirement
as
usize
);
let
sentries
:
Vec
<
_
>
=
self
.get_sentries
(
sentry_requirement
as
usize
)
.into_iter
()
.filter
(|
sentry
|
sentry
.0
!=
node
.0
)
.collect
();
distance
.sentries
=
sentries
.len
()
as
u32
;
let
success
=
area
.iter
()
.filter
(|
n
|
sentries
.contains
(
&
n
))
.count
()
as
u32
;
distance
.reached
=
area
.len
()
as
u32
;
let
sentries
=
sentries
.len
()
as
u32
;
distance
.success
=
area
.iter
()
.filter
(|
n
|
sentries
.contains
(
&
n
))
.count
()
as
u32
;
distance
.outdistanced
=
let
distance
=
WotDistance
{
f64
::
from
(
distance
.success
)
<
x_percent
*
f64
::
from
(
distance
.sentries
);
sentries
,
reached
:
(
area
.len
()
-
1
)
as
u32
,
success
:
success
,
outdistanced
:
f64
::
from
(
success
)
<
x_percent
*
f64
::
from
(
sentries
),
};
Some
(
distance
)
Some
(
distance
)
}
}
...
@@ -319,16 +319,8 @@ impl WebOfTrust for RustyWebOfTrust {
...
@@ -319,16 +319,8 @@ impl WebOfTrust for RustyWebOfTrust {
/// Test if a node is outdistanced in the network.
/// Test if a node is outdistanced in the network.
/// Returns `Node` if this node doesn't exist.
/// Returns `Node` if this node doesn't exist.
fn
is_outdistanced
(
&
self
,
params
:
WotDistanceParameters
)
->
Option
<
bool
>
{
fn
is_outdistanced
(
&
self
,
params
:
WotDistanceParameters
)
->
Option
<
bool
>
{
let
WotDistanceParameters
{
node
,
..
}
=
params
;
self
.compute_distance
(
params
)
.map
(|
result
|
result
.outdistanced
)
if
node
.0
>=
self
.size
()
{
None
}
else
{
match
self
.compute_distance
(
params
)
{
Some
(
distance
)
=>
Some
(
distance
.outdistanced
),
None
=>
None
,
}
}
}
}
}
}
...
...
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