diff --git a/bin/dnetview/dnetview_config.toml b/bin/dnetview/dnetview_config.toml index ee08665d0..bccbaa8e7 100644 --- a/bin/dnetview/dnetview_config.toml +++ b/bin/dnetview/dnetview_config.toml @@ -5,13 +5,13 @@ [[nodes]] name = "Node 1" -node_id = "tcp://127.0.0.1:8000" +rpc_url = "tcp://127.0.0.1:8000" [[nodes]] name = "Node 2" -node_id = "tcp://127.0.0.1:7777" +rpc_url = "tcp://127.0.0.1:7777" [[nodes]] name = "Node 3" -node_id = "tcp://127.0.0.1:1234" +rpc_url = "tcp://127.0.0.1:1234" diff --git a/bin/dnetview/src/config.rs b/bin/dnetview/src/config.rs index 1d7e885ec..8a4adbc91 100644 --- a/bin/dnetview/src/config.rs +++ b/bin/dnetview/src/config.rs @@ -9,6 +9,6 @@ pub struct DnvConfig { #[derive(Clone, Serialize, Deserialize, Debug)] pub struct IrcNode { - pub node_id: String, - //pub rpc_url: String, + pub name: String, + pub rpc_url: String, } diff --git a/bin/dnetview/src/main.rs b/bin/dnetview/src/main.rs index 2a043fcb9..b3e62fef4 100644 --- a/bin/dnetview/src/main.rs +++ b/bin/dnetview/src/main.rs @@ -36,11 +36,12 @@ use dnetview::{ struct DNetView { url: Url, + name: String, } impl DNetView { - pub fn new(url: Url) -> Self { - Self { url } + pub fn new(url: Url, name: String) -> Self { + Self { url, name } } async fn request(&self, r: jsonrpc::JsonRequest) -> Result { @@ -134,7 +135,7 @@ async fn main() -> Result<()> { async fn run_rpc(config: &DnvConfig, ex: Arc>, model: Arc) -> Result<()> { for node in config.nodes.clone() { - let client = DNetView::new(Url::parse(&node.node_id)?); + let client = DNetView::new(Url::parse(&node.rpc_url)?, node.name); ex.spawn(poll(client, model.clone())).detach(); } Ok(()) @@ -230,10 +231,8 @@ async fn poll(client: DNetView, model: Arc) -> Result<()> { let infos = NodeInfo { outbound: oconnects, manual: mconnects, inbound: iconnects }; let mut node_info = FxHashMap::default(); - // TODO: here we are setting the RPC url as the node_id. - // next step is to read the string variable 'name' from dnetview.toml - let node_id = &client.url.as_str(); - node_info.insert(&node_id, infos.clone()); + let node_name = &client.name.as_str(); + node_info.insert(&node_name, infos.clone()); for (key, value) in node_info.clone() { model.id_list.node_id.lock().await.insert(key.to_string().clone());