lunar-mining 4 жил өмнө
parent
commit
e1a674f8e2
1 өөрчлөгдсөн 11 нэмэгдсэн , 39 устгасан
  1. 11 39
      bin/ircd/src/main.rs

+ 11 - 39
bin/ircd/src/main.rs

@@ -82,7 +82,7 @@ async fn process_user_input(
 ) -> Result<()> {
     if line.is_empty() {
         warn!("Received empty line from {}. Closing connection.", peer_addr);
-        return Err(Error::ChannelStopped)
+        return Err(Error::ChannelStopped);
     }
     assert!(&line[(line.len() - 1)..] == "\n");
     // Remove the \n character
@@ -92,7 +92,7 @@ async fn process_user_input(
 
     if let Err(err) = connection.update(line, p2p.clone()).await {
         warn!("Connection error: {} for {}", err, peer_addr);
-        return Err(Error::ChannelStopped)
+        return Err(Error::ChannelStopped);
     }
 
     Ok(())
@@ -103,14 +103,14 @@ async fn start(executor: Arc<Executor<'_>>, options: ProgramOptions) -> Result<(
         Ok(listener) => listener,
         Err(err) => {
             error!("Bind listener failed: {}", err);
-            return Err(Error::OperationFailed)
+            return Err(Error::OperationFailed);
         }
     };
     let local_addr = match listener.get_ref().local_addr() {
         Ok(addr) => addr,
         Err(err) => {
             error!("Failed to get local address: {}", err);
-            return Err(Error::OperationFailed)
+            return Err(Error::OperationFailed);
         }
     };
     info!("Listening on {}", local_addr);
@@ -135,15 +135,13 @@ async fn start(executor: Arc<Executor<'_>>, options: ProgramOptions) -> Result<(
     let (sender, recvr) = async_channel::unbounded();
     let seen_privmsg_ids2 = seen_privmsg_ids.clone();
     let sender2 = sender.clone();
-    registry.register(
-        !net::SESSION_SEED,
-        move |channel, p2p| {
+    registry
+        .register(!net::SESSION_SEED, move |channel, p2p| {
             let sender = sender2.clone();
             let seen_privmsg_ids = seen_privmsg_ids2.clone();
-            async move {
-                ProtocolPrivMsg::new(channel, sender, seen_privmsg_ids, p2p).await
-            }
-        }).await;
+            async move { ProtocolPrivMsg::new(channel, sender, seen_privmsg_ids, p2p).await }
+        })
+        .await;
 
     //
     // p2p network main instance
@@ -179,7 +177,7 @@ async fn start(executor: Arc<Executor<'_>>, options: ProgramOptions) -> Result<(
             Ok((s, a)) => (s, a),
             Err(err) => {
                 error!("Error listening for connections: {}", err);
-                return Err(Error::ServiceStopped)
+                return Err(Error::ServiceStopped);
             }
         };
         info!("Accepted client: {}", peer_addr);
@@ -198,7 +196,7 @@ struct JsonRpcInterface {}
 impl RequestHandler for JsonRpcInterface {
     async fn handle_request(&self, req: JsonRequest, _executor: Arc<Executor<'_>>) -> JsonResult {
         if req.params.as_array().is_none() {
-            return JsonResult::Err(jsonerr(InvalidParams, None, req.id))
+            return JsonResult::Err(jsonerr(InvalidParams, None, req.id));
         }
 
         debug!(target: "RPC", "--> {}", serde_json::to_string(&req).unwrap());
@@ -217,32 +215,6 @@ impl JsonRpcInterface {
     async fn say_hello(&self, id: Value, _params: Value) -> JsonResult {
         JsonResult::Resp(jsonresp(json!("hello world"), id))
     }
-
-    //--> {"jsonrpc": "2.0", "method": "poll", "params": [], "id": 42}
-    // <-- {"jsonrpc": "2.0", "result": {"nodeID": [], "nodeinfo" [], "id": 42}
-    async fn get_info(&self, id: Value, _params: Value) -> JsonResult {
-        let resp: serde_json::Value = json!({
-            "nodes": [{
-                "id": "dfk34123kl213kp213sd",
-                "connections": 1,
-                "message": "gm",
-                "is_active": true,
-            },
-            {
-                "id": "138032139034903499s8",
-                "connections": 3,
-                "message": "ok",
-                "is_active": false,
-            },
-            {
-                "id": "123423ml1k2j3ll123kl",
-                "connections": 6,
-                "message": "lol",
-                "is_active": true,
-            }]
-        });
-        JsonResult::Resp(jsonresp(resp, id))
-    }
 }
 
 fn main() -> Result<()> {