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
ebdf8e78
Commit
ebdf8e78
authored
7 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[tui] remove chrono dependance
parent
d6218cdb
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!58
Resolve "Add crates blockchain, conf, core, dal, message, module, network, tui and ws2p"
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Cargo.lock
+0
-1
0 additions, 1 deletion
Cargo.lock
tui/Cargo.toml
+0
-1
0 additions, 1 deletion
tui/Cargo.toml
tui/lib.rs
+28
-12
28 additions, 12 deletions
tui/lib.rs
with
28 additions
and
14 deletions
Cargo.lock
+
0
−
1
View file @
ebdf8e78
...
...
@@ -359,7 +359,6 @@ dependencies = [
name = "duniter-tui"
version = "0.1.0"
dependencies = [
"chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"duniter-conf 0.1.0",
"duniter-crypto 0.1.2",
"duniter-dal 0.1.0",
...
...
This diff is collapsed.
Click to expand it.
tui/Cargo.toml
+
0
−
1
View file @
ebdf8e78
...
...
@@ -9,7 +9,6 @@ license = "AGPL-3.0"
path
=
"lib.rs"
[dependencies]
chrono
=
"0.4.2"
duniter-conf
=
{
path
=
"../conf"
}
duniter-crypto
=
{
path
=
"../crypto"
}
duniter-dal
=
{
path
=
"../dal"
}
...
...
This diff is collapsed.
Click to expand it.
tui/lib.rs
+
28
−
12
View file @
ebdf8e78
...
...
@@ -26,7 +26,6 @@
#[macro_use]
extern
crate
log
;
extern
crate
chrono
;
extern
crate
duniter_conf
;
extern
crate
duniter_crypto
;
extern
crate
duniter_dal
;
...
...
@@ -37,7 +36,6 @@ extern crate duniter_network;
extern
crate
serde_json
;
extern
crate
termion
;
use
chrono
::
prelude
::
*
;
use
duniter_crypto
::
keys
::
ed25519
;
use
duniter_dal
::
dal_event
::
DALEvent
;
use
duniter_message
::
DuniterMessage
;
...
...
@@ -106,7 +104,7 @@ impl TuiModuleDatas {
fn
draw_term
<
W
:
Write
>
(
&
self
,
stdout
:
&
mut
RawTerminal
<
W
>
,
start_time
:
&
Da
teTime
<
Utc
>
,
start_time
:
Sys
te
m
Time
,
heads_cache
:
&
HashMap
<
NodeFullId
,
NetworkHead
>
,
heads_index
:
usize
,
out_connections_status
:
&
HashMap
<
NodeFullId
,
Connection
>
,
...
...
@@ -190,8 +188,13 @@ impl TuiModuleDatas {
)
.unwrap
();
}
else
{
let
mut
count_conns
=
0
;
let
conns_index_use
=
if
conns_index
>
(
out_established_conns
.len
()
-
5
)
{
let
max_index
=
if
out_established_conns
.len
()
<
5
{
0
}
else
{
out_established_conns
.len
()
-
5
};
let
conns_index_use
=
if
conns_index
>
max_index
{
max_index
}
else
{
conns_index
};
...
...
@@ -322,11 +325,21 @@ impl TuiModuleDatas {
}
// Draw footer
let
runtime_in_secs
=
Utc
::
now
()
.timestamp
()
-
(
*
start_time
)
.timestamp
();
let
runtime_str
=
DateTime
::
<
Utc
>
::
from_utc
(
NaiveDateTime
::
from_timestamp
(
runtime_in_secs
,
0
),
Utc
)
let
mut
runtime_in_secs
=
SystemTime
::
now
()
.duration_since
(
start_time
)
.expect
(
"Fail to get runtime"
)
.as_secs
();
let
runtime_hours
=
runtime_in_secs
/
3600
;
runtime_in_secs
-=
runtime_hours
*
3600
;
let
runtime_mins
=
runtime_in_secs
/
60
;
let
runtime_secs
=
runtime_in_secs
%
60
;
let
runtime_str
=
format!
(
"{:02}:{:02}:{:02}"
,
runtime_hours
,
runtime_mins
,
runtime_secs
);
/*DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp(runtime_in_secs, 0), Utc)
.format("%H:%M:%S")
.to_string
();
.to_string();
*/
write!
(
stdout
,
"{}{}{}runtime : {}"
,
...
...
@@ -377,7 +390,7 @@ impl DuniterModule<ed25519::PublicKey, ed25519::KeyPair, DuniterMessage> for Tui
main_sender
:
mpsc
::
Sender
<
RooterThreadMessage
<
DuniterMessage
>>
,
load_conf_only
:
bool
,
)
->
Result
<
(),
ModuleInitError
>
{
let
start_time
:
DateTime
<
Utc
>
=
Utc
::
now
();
let
start_time
=
SystemTime
::
now
();
//
: DateTime<Utc> = Utc::now();
// load conf
let
_conf
=
TuiModuleDatas
::
parse_tui_conf
(
module_conf
);
...
...
@@ -445,7 +458,7 @@ impl DuniterModule<ed25519::PublicKey, ed25519::KeyPair, DuniterMessage> for Tui
let
mut
last_draw
=
SystemTime
::
now
();
tui
.draw_term
(
&
mut
stdout
,
&
start_time
,
start_time
,
&
tui
.heads_cache
,
tui
.heads_index
,
&
tui
.connections_status
,
...
...
@@ -520,7 +533,10 @@ impl DuniterModule<ed25519::PublicKey, ed25519::KeyPair, DuniterMessage> for Tui
if
let
Some
(
conn
)
=
tui
.connections_status
.get
(
node_full_id
)
{
if
*
status
==
12
&&
(
*
conn
)
.status
!=
12
{
tui
.established_conns_count
+=
1
;
}
else
if
*
status
!=
12
&&
(
*
conn
)
.status
==
12
{
}
else
if
*
status
!=
12
&&
(
*
conn
)
.status
==
12
&&
tui
.established_conns_count
>
0
{
tui
.established_conns_count
-=
1
;
}
};
...
...
@@ -641,7 +657,7 @@ impl DuniterModule<ed25519::PublicKey, ed25519::KeyPair, DuniterMessage> for Tui
last_draw
=
now
;
tui
.draw_term
(
&
mut
stdout
,
&
start_time
,
start_time
,
&
tui
.heads_cache
,
tui
.heads_index
,
&
tui
.connections_status
,
...
...
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