dnetview: add line numbers to msg log

This commit is contained in:
lunar-mining
2022-06-25 15:39:33 +02:00
parent 41289b14bc
commit 7d3f7ecc14
2 changed files with 10 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};
use darkfi::util::NanoTimestamp;
// Mutex<FxHashMap<ConnectInfo.id, Vec<(NanoTimestamp, send, recv)>>>
type MsgLogMutex = Mutex<FxHashMap<String, Vec<(NanoTimestamp, String, String)>>>;
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]

View File

@@ -277,14 +277,16 @@ impl View {
let log = self.msg_log.get(&connect.id);
match log {
Some(values) => {
for (t, k, v) in values {
for (i, (t, k, v)) in values.into_iter().enumerate() {
lines.push(Spans::from(match k.as_str() {
"send" => {
Span::styled(format!("{} S: {}", t, v), style)
}
"recv" => {
Span::styled(format!("{} R: {}", t, v), style)
}
"send" => Span::styled(
format!("{} {} S: {}", i, t, v),
style,
),
"recv" => Span::styled(
format!("{} {} R: {}", i, t, v),
style,
),
data => {
return Err(DnetViewError::UnexpectedData(data.to_string()))
}