Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
R
railgun-routing-server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
railgun-routing-server
Commits
473d1dae
Commit
473d1dae
authored
Jan 07, 2026
by
nanamicat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
metric
parent
5d5295c4
Pipeline
#42461
passed with stages
in 46 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
9 deletions
+9
-9
src/quality.rs
src/quality.rs
+1
-7
src/router.rs
src/router.rs
+8
-2
No files found.
src/quality.rs
View file @
473d1dae
...
...
@@ -18,13 +18,7 @@ impl Quality {
}
pub
fn
metric
(
&
self
)
->
i32
{
assert
!
(
0.0
<=
self
.reliability
&&
self
.reliability
<=
1.0
);
if
self
.reliability
==
0.0
{
i32
::
MAX
}
else
{
self
.delay
+
((
1.0
-
self
.reliability
)
*
3000.0
)
.round
()
as
i32
+
self
.cost
as
i32
}
self
.delay
+
((
1.0
-
self
.reliability
)
*
3000.0
)
.round
()
as
i32
+
self
.cost
as
i32
}
}
...
...
src/router.rs
View file @
473d1dae
...
...
@@ -119,6 +119,7 @@ impl Router {
updating
.router_id
=
0
;
self
.via
.append
(
&
mut
updating
.message.via
);
self
.plan
.append
(
&
mut
updating
.message.plan
);
self
.last_update
=
now
;
}
None
}
else
if
!
self
.is_online
()
{
...
...
@@ -147,6 +148,7 @@ impl Router {
let
penalty
=
self
.penalty
(
now
);
let
mut
changed_via
:
BTreeMap
<
u8
,
u8
>
=
BTreeMap
::
new
();
// let mut metric: BTreeMap<u8, i32> = BTreeMap::new();
let
mut
overcome
=
false
;
for
to
in
routers
.values
()
.filter
(|
&
r
|
r
!=
self
)
{
let
current_router
=
routers
.get
(
self
.via
.get
(
&
to
.id
)
.unwrap
())
.unwrap
();
...
...
@@ -161,16 +163,20 @@ impl Router {
match
candidate
.iter
()
.min_by_key
(|(
_
,
m
)|
m
)
{
None
if
current_router
!=
to
=>
{
// 无论如何都不可达就标记为直连
overcome
=
true
;
changed_via
.insert
(
to
.id
,
to
.id
);
}
Some
((
best_router
,
best_metric
))
if
current_router
!=
*
best_router
&&
(
*
best_metric
+
penalty
<
current_metric
)
=>
{
Some
((
best_router
,
best_metric
))
if
current_router
!=
*
best_router
&&
*
best_metric
<
current_metric
=>
{
if
*
best_metric
+
penalty
<
current_metric
{
overcome
=
true
}
changed_via
.insert
(
to
.id
,
best_router
.id
);
}
_
=>
{}
}
}
if
changed_via
.len
()
>
0
{
if
overcome
{
Some
(
Downlink
{
action
:
MessageType
::
Update
,
version
:
self
.version
+
1
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment