فهرست منبع

dnetview: enable memory leak

we enable dnet logs at the start of dnetview. we never disable them, so
this makes the switch logic pointless and reintroduces a memory leak.

we will push an update soon that also disables dnet logs.
lunar-mining 3 سال پیش
والد
کامیت
03d5c6f1d3
2فایلهای تغییر یافته به همراه14 افزوده شده و 0 حذف شده
  1. 4 0
      bin/dnetview/src/parser.rs
  2. 10 0
      bin/dnetview/src/rpc.rs

+ 4 - 0
bin/dnetview/src/parser.rs

@@ -65,6 +65,10 @@ impl DataParser {
             // On any failure, sleep and retry.
             match RpcConnect::new(Url::parse(&node.rpc_url)?, node.name.clone()).await {
                 Ok(client) => {
+                    // We start by enabling dnet
+                    if let Err(e) = client.dnet_enable(true).await {
+                        error!("dnet_enable error: {:?}", e);
+                    }
                     if let Err(e) = self.poll(&node, client).await {
                         error!("Poll execution error: {:?}", e);
                     }

+ 10 - 0
bin/dnetview/src/rpc.rs

@@ -53,6 +53,16 @@ impl RpcConnect {
             Err(e) => Err(DnetViewError::Darkfi(e)),
         }
     }
+    
+    // --> {"jsonrpc": "2.0", "method": "dnet_switch", "params": [true], "id": 42}
+    // <-- {"jsonrpc": "2.0", "result": true, "id": 42}
+    pub async fn dnet_enable(&self, params: bool) -> DnetViewResult<Value> {
+        let req = JsonRequest::new("dnet_switch", json!([params]));
+        match self.rpc_client.request(req).await {
+            Ok(req) => Ok(req),
+            Err(e) => Err(DnetViewError::Darkfi(e)),
+        }
+    }
 
     // --> {"jsonrpc": "2.0", "method": "get_consensus_info", "params": [], "id": 42}
     // <-- {"jsonrpc": "2.0", "result": {"nodeID": [], "nodeinfo" [], "id": 42}