Kaynağa Gözat

ircd: Changes for new serial module.

Luther Blissett 3 yıl önce
ebeveyn
işleme
fb372fda77

+ 1 - 1
bin/ircd/src/chains.rs

@@ -5,7 +5,7 @@ use chrono::Utc;
 use fxhash::FxHashMap;
 use fxhash::FxHashMap;
 use ripemd::{Digest, Ripemd256};
 use ripemd::{Digest, Ripemd256};
 
 
-use darkfi::util::serial::{SerialDecodable, SerialEncodable};
+use darkfi::serial::{SerialDecodable, SerialEncodable};
 
 
 const MAX_CHAIN_SIZE: usize = 4096;
 const MAX_CHAIN_SIZE: usize = 4096;
 
 

+ 2 - 2
bin/ircd/src/irc/mod.rs

@@ -1,7 +1,7 @@
-use async_std::{net::TcpListener, sync::Arc};
 use std::{fs::File, net::SocketAddr};
 use std::{fs::File, net::SocketAddr};
 
 
 use async_executor::Executor;
 use async_executor::Executor;
+use async_std::{net::TcpListener, sync::Arc};
 use futures::{io::BufReader, AsyncRead, AsyncReadExt, AsyncWrite};
 use futures::{io::BufReader, AsyncRead, AsyncReadExt, AsyncWrite};
 use futures_rustls::{rustls, TlsAcceptor};
 use futures_rustls::{rustls, TlsAcceptor};
 use fxhash::FxHashMap;
 use fxhash::FxHashMap;
@@ -10,7 +10,7 @@ use log::{error, info};
 use darkfi::{
 use darkfi::{
     net::P2pPtr,
     net::P2pPtr,
     system::SubscriberPtr,
     system::SubscriberPtr,
-    util::{expand_path, path::get_config_path},
+    util::path::{expand_path, get_config_path},
     Error, Result,
     Error, Result,
 };
 };
 
 

+ 3 - 4
bin/ircd/src/main.rs

@@ -1,8 +1,8 @@
-use async_std::sync::Arc;
 use std::fmt;
 use std::fmt;
 
 
 use async_channel::Receiver;
 use async_channel::Receiver;
 use async_executor::Executor;
 use async_executor::Executor;
+use async_std::sync::Arc;
 
 
 use log::{info, warn};
 use log::{info, warn};
 use rand::rngs::OsRng;
 use rand::rngs::OsRng;
@@ -15,11 +15,10 @@ use darkfi::{
     rpc::server::listen_and_serve,
     rpc::server::listen_and_serve,
     system::{Subscriber, SubscriberPtr},
     system::{Subscriber, SubscriberPtr},
     util::{
     util::{
+        async_util::sleep,
         cli::{get_log_config, get_log_level, spawn_config},
         cli::{get_log_config, get_log_level, spawn_config},
-        expand_path,
         file::save_json_file,
         file::save_json_file,
-        path::get_config_path,
-        sleep,
+        path::{expand_path, get_config_path},
     },
     },
     Result,
     Result,
 };
 };

+ 5 - 6
bin/ircd/src/mvc.rs

@@ -13,11 +13,10 @@ use structopt_toml::StructOptToml;
 
 
 use darkfi::{
 use darkfi::{
     async_daemonize,
     async_daemonize,
+    serial::{Decodable, Encodable, ReadExt, SerialDecodable, SerialEncodable},
     util::{
     util::{
         cli::{get_log_config, get_log_level, spawn_config},
         cli::{get_log_config, get_log_level, spawn_config},
-        expand_path,
-        path::get_config_path,
-        serial::{Decodable, Encodable, ReadExt, SerialDecodable, SerialEncodable},
+        path::{expand_path, get_config_path},
     },
     },
     Result,
     Result,
 };
 };
@@ -68,7 +67,7 @@ enum EventAction {
 }
 }
 
 
 impl Encodable for EventAction {
 impl Encodable for EventAction {
-    fn encode<S: io::Write>(&self, mut s: S) -> Result<usize> {
+    fn encode<S: io::Write>(&self, mut s: S) -> core::result::Result<usize, io::Error> {
         match self {
         match self {
             Self::PrivMsg(event) => {
             Self::PrivMsg(event) => {
                 let mut len = 0;
                 let mut len = 0;
@@ -81,11 +80,11 @@ impl Encodable for EventAction {
 }
 }
 
 
 impl Decodable for EventAction {
 impl Decodable for EventAction {
-    fn decode<D: io::Read>(mut d: D) -> Result<Self> {
+    fn decode<D: io::Read>(mut d: D) -> core::result::Result<Self, io::Error> {
         let type_id = d.read_u8()?;
         let type_id = d.read_u8()?;
         match type_id {
         match type_id {
             0 => Ok(Self::PrivMsg(PrivMsgEvent::decode(d)?)),
             0 => Ok(Self::PrivMsg(PrivMsgEvent::decode(d)?)),
-            _ => Err(darkfi::Error::ParseFailed("Bad type ID byte for Event")),
+            _ => Err(io::Error::new(io::ErrorKind::Other, "Bad type ID byte for Event")),
         }
         }
     }
     }
 }
 }

+ 1 - 1
bin/ircd/src/privmsg.rs

@@ -1,7 +1,7 @@
 use chrono::Utc;
 use chrono::Utc;
 use rand::{rngs::OsRng, RngCore};
 use rand::{rngs::OsRng, RngCore};
 
 
-use darkfi::util::serial::{SerialDecodable, SerialEncodable};
+use darkfi::serial::{SerialDecodable, SerialEncodable};
 
 
 pub type PrivmsgId = u64;
 pub type PrivmsgId = u64;
 
 

+ 2 - 2
bin/ircd/src/protocol_privmsg.rs

@@ -1,7 +1,7 @@
-use async_std::sync::Arc;
 use std::cmp::Ordering;
 use std::cmp::Ordering;
 
 
 use async_executor::Executor;
 use async_executor::Executor;
+use async_std::sync::Arc;
 use async_trait::async_trait;
 use async_trait::async_trait;
 use chrono::Utc;
 use chrono::Utc;
 use log::debug;
 use log::debug;
@@ -9,7 +9,7 @@ use rand::{rngs::OsRng, RngCore};
 
 
 use darkfi::{
 use darkfi::{
     net,
     net,
-    util::serial::{SerialDecodable, SerialEncodable},
+    serial::{SerialDecodable, SerialEncodable},
     Result,
     Result,
 };
 };
 
 

+ 3 - 5
bin/ircd/src/protocol_privmsg2.rs

@@ -1,7 +1,7 @@
-use async_std::sync::{Arc, Mutex};
 use std::collections::VecDeque;
 use std::collections::VecDeque;
 
 
 use async_executor::Executor;
 use async_executor::Executor;
+use async_std::sync::{Arc, Mutex};
 use async_trait::async_trait;
 use async_trait::async_trait;
 use chrono::Utc;
 use chrono::Utc;
 use fxhash::FxHashMap;
 use fxhash::FxHashMap;
@@ -10,10 +10,8 @@ use rand::{rngs::OsRng, RngCore};
 
 
 use darkfi::{
 use darkfi::{
     net,
     net,
-    util::{
-        serial::{SerialDecodable, SerialEncodable},
-        sleep,
-    },
+    serial::{SerialDecodable, SerialEncodable},
+    util::async_util::sleep,
     Result,
     Result,
 };
 };