dnetview: add timestamp to msg log

This commit is contained in:
lunar-mining
2022-05-11 11:37:41 +02:00
committed by parazyd
parent bd9382b1e5
commit 0d5e1930e7
3 changed files with 13 additions and 13 deletions

View File

@@ -304,9 +304,9 @@ async fn parse_inbound(inbound: &Value, node_id: &String) -> DnetViewResult<Sess
let state = "state".to_string();
let parent = parent.clone();
let msg_values = node.unwrap().get("log").unwrap().as_array().unwrap();
let mut msg_log: Vec<(String, String)> = Vec::new();
let mut msg_log: Vec<(u64, String, String)> = Vec::new();
for msg in msg_values {
let msg: (String, String) = serde_json::from_value(msg.clone())?;
let msg: (u64, String, String) = serde_json::from_value(msg.clone())?;
msg_log.push(msg);
}
let is_empty = false;
@@ -411,9 +411,9 @@ async fn parse_outbound(outbound: &Value, node_id: &String) -> DnetViewResult<Se
let state = state.as_str().unwrap().to_string();
let parent = parent.clone();
let msg_values = channel["log"].as_array().unwrap();
let mut msg_log: Vec<(String, String)> = Vec::new();
let mut msg_log: Vec<(u64, String, String)> = Vec::new();
for msg in msg_values {
let msg: (String, String) = serde_json::from_value(msg.clone())?;
let msg: (u64, String, String) = serde_json::from_value(msg.clone())?;
msg_log.push(msg);
}
let is_empty = false;

View File

@@ -20,7 +20,7 @@ pub enum SelectableObject {
pub struct Model {
pub ids: Mutex<FxHashSet<String>>,
pub nodes: Mutex<FxHashMap<String, NodeInfo>>,
pub msg_log: Mutex<FxHashMap<String, Vec<(String, String)>>>,
pub msg_log: Mutex<FxHashMap<String, Vec<(u64, String, String)>>>,
pub selectables: Mutex<FxHashMap<String, SelectableObject>>,
}
@@ -28,7 +28,7 @@ impl Model {
pub fn new(
ids: Mutex<FxHashSet<String>>,
nodes: Mutex<FxHashMap<String, NodeInfo>>,
msg_log: Mutex<FxHashMap<String, Vec<(String, String)>>>,
msg_log: Mutex<FxHashMap<String, Vec<(u64, String, String)>>>,
selectables: Mutex<FxHashMap<String, SelectableObject>>,
) -> Model {
Model { ids, nodes, msg_log, selectables }
@@ -81,7 +81,7 @@ pub struct ConnectInfo {
pub addr: String,
pub state: String,
pub parent: String,
pub msg_log: Vec<(String, String)>,
pub msg_log: Vec<(u64, String, String)>,
pub is_empty: bool,
pub last_msg: String,
pub last_status: String,
@@ -93,7 +93,7 @@ impl ConnectInfo {
addr: String,
state: String,
parent: String,
msg_log: Vec<(String, String)>,
msg_log: Vec<(u64, String, String)>,
is_empty: bool,
last_msg: String,
last_status: String,

View File

@@ -20,7 +20,7 @@ use log::debug;
#[derive(Debug)]
pub struct View {
pub nodes: NodeInfoView,
pub msg_log: FxHashMap<String, Vec<(String, String)>>,
pub msg_log: FxHashMap<String, Vec<(u64, String, String)>>,
pub active_ids: IdListView,
pub selectables: FxHashMap<String, SelectableObject>,
}
@@ -28,7 +28,7 @@ pub struct View {
impl View {
pub fn new(
nodes: NodeInfoView,
msg_log: FxHashMap<String, Vec<(String, String)>>,
msg_log: FxHashMap<String, Vec<(u64, String, String)>>,
active_ids: IdListView,
selectables: FxHashMap<String, SelectableObject>,
) -> View {
@@ -38,7 +38,7 @@ impl View {
pub fn update(
&mut self,
nodes: FxHashMap<String, NodeInfo>,
msg_log: FxHashMap<String, Vec<(String, String)>>,
msg_log: FxHashMap<String, Vec<(u64, String, String)>>,
selectables: FxHashMap<String, SelectableObject>,
) {
self.update_nodes(nodes);
@@ -73,7 +73,7 @@ impl View {
}
}
fn update_msg_log(&mut self, msg_log: FxHashMap<String, Vec<(String, String)>>) {
fn update_msg_log(&mut self, msg_log: FxHashMap<String, Vec<(u64, String, String)>>) {
for (id, msg) in msg_log {
self.msg_log.insert(id, msg);
}
@@ -207,7 +207,7 @@ impl View {
let log = self.msg_log.get(&connect.id);
match log {
Some(values) => {
for (k, v) in values {
for (t, k, v) in values {
lines.push(Spans::from(match k.as_str() {
"send" => Span::styled(format!("S: {}", v), style),
"recv" => Span::styled(format!("R: {}", v), style),