diff --git a/bin/dnetview/README.md b/bin/dnetview/README.md index 84891c976..de2dd05a1 100644 --- a/bin/dnetview/README.md +++ b/bin/dnetview/README.md @@ -79,12 +79,10 @@ enum SelectableObject { ``` Id is a randomly generated number to correspond to the received info. -Each SelectableObject corresponds to an info HashMap. +We copy all of these values into a info hashmap. ``` -NodeInfo = Hashmap -SessionInfo = Hashmap -ConnectInfo = Hashmap +infos = Mutex> ``` We use mutexes to protect the data because we are updating it diff --git a/bin/dnetview/src/main.rs b/bin/dnetview/src/main.rs index 4b3a54ddc..834ccb430 100644 --- a/bin/dnetview/src/main.rs +++ b/bin/dnetview/src/main.rs @@ -107,12 +107,10 @@ async fn main() -> Result<()> { terminal.clear()?; - let id_set = Mutex::new(FxHashSet::default()); - let node_info = Mutex::new(FxHashMap::default()); - let session_info = Mutex::new(FxHashMap::default()); - let connect_info = Mutex::new(FxHashMap::default()); + let ids = Mutex::new(FxHashSet::default()); + let infos = Mutex::new(FxHashMap::default()); - let model = Arc::new(Model::new(id_set, node_info, session_info, connect_info)); + let model = Arc::new(Model::new(ids, infos)); let nthreads = num_cpus::get(); let (signal, shutdown) = async_channel::unbounded::<()>(); diff --git a/bin/dnetview/src/model.rs b/bin/dnetview/src/model.rs index 7642afb81..a71a33e7a 100644 --- a/bin/dnetview/src/model.rs +++ b/bin/dnetview/src/model.rs @@ -11,21 +11,21 @@ pub enum SelectableObject { Connect(ConnectInfo), } +// how do you know which type of thing the hashmap belongs to +// we don't need to ?? +// given an id, return the type of Selectable +// pub struct Model { - pub id_set: Mutex>, - pub node_info: Mutex>, - pub session_info: Mutex>, - pub connect_info: Mutex>, + pub ids: Mutex>, + pub infos: Mutex>, } impl Model { pub fn new( - id_set: Mutex>, - node_info: Mutex>, - session_info: Mutex>, - connect_info: Mutex>, + ids: Mutex>, + infos: Mutex>, ) -> Model { - Model { id_set, node_info, session_info, connect_info } + Model { ids, infos } } } @@ -41,26 +41,26 @@ impl Model { // } //} -pub struct InfoList { - pub index: Mutex, - pub infos: Mutex>, -} - -impl InfoList { - pub fn new() -> InfoList { - let index = 0; - let index = Mutex::new(index); - let infos = Mutex::new(FxHashMap::default()); - - InfoList { index, infos } - } -} - -impl Default for InfoList { - fn default() -> Self { - Self::new() - } -} +//pub struct InfoList { +// pub index: Mutex, +// pub infos: Mutex>, +//} +// +//impl InfoList { +// pub fn new() -> InfoList { +// let index = 0; +// let index = Mutex::new(index); +// let infos = Mutex::new(FxHashMap::default()); +// +// InfoList { index, infos } +// } +//} +// +//impl Default for InfoList { +// fn default() -> Self { +// Self::new() +// } +//} type NodeId = u32; type SessionId = u32; diff --git a/bin/dnetview/src/ui.rs b/bin/dnetview/src/ui.rs index 0dd0037bf..d6b63daca 100644 --- a/bin/dnetview/src/ui.rs +++ b/bin/dnetview/src/ui.rs @@ -19,6 +19,7 @@ pub fn ui(f: &mut Frame<'_, B>, mut view: View) { let style = Style::default(); // lines.push(sublist) + // either have one hashmap w value as enum or have type info in hashset for id in &view.id_list.node_id { let id_span = Span::raw(id.to_string()); let mut lines = vec![Spans::from(id_span)];