Explorar el Código

bin/ircd: change seen_msg_ids from vector to fixed ringbuffer

ghassmo hace 4 años
padre
commit
aa43e01e3a
Se han modificado 2 ficheros con 4 adiciones y 2 borrados
  1. 3 1
      bin/ircd/src/main.rs
  2. 1 1
      bin/ircd/src/privmsg.rs

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

@@ -39,6 +39,7 @@ use crate::{
     settings::{parse_configured_channels, Args, ChannelInfo, CONFIG_FILE, CONFIG_FILE_CONTENTS},
     settings::{parse_configured_channels, Args, ChannelInfo, CONFIG_FILE, CONFIG_FILE_CONTENTS},
 };
 };
 
 
+const SIZE_OF_MSG_IDSS_BUFFER: usize = 65536;
 const SIZE_OF_MSGS_BUFFER: usize = 4096;
 const SIZE_OF_MSGS_BUFFER: usize = 4096;
 pub const MAXIMUM_LENGTH_OF_MESSAGE: usize = 1024;
 pub const MAXIMUM_LENGTH_OF_MESSAGE: usize = 1024;
 pub const MAXIMUM_LENGTH_OF_NICKNAME: usize = 32;
 pub const MAXIMUM_LENGTH_OF_NICKNAME: usize = 32;
@@ -144,7 +145,8 @@ impl Ircd {
 
 
 async_daemonize!(realmain);
 async_daemonize!(realmain);
 async fn realmain(settings: Args, executor: Arc<Executor<'_>>) -> Result<()> {
 async fn realmain(settings: Args, executor: Arc<Executor<'_>>) -> Result<()> {
-    let seen_msg_ids = Arc::new(Mutex::new(vec![]));
+    let seen_msg_ids =
+        Arc::new(Mutex::new(ringbuffer::AllocRingBuffer::with_capacity(SIZE_OF_MSG_IDSS_BUFFER)));
     let privmsgs_buffer: PrivmsgsBuffer =
     let privmsgs_buffer: PrivmsgsBuffer =
         Arc::new(Mutex::new(ringbuffer::AllocRingBuffer::with_capacity(SIZE_OF_MSGS_BUFFER)));
         Arc::new(Mutex::new(ringbuffer::AllocRingBuffer::with_capacity(SIZE_OF_MSGS_BUFFER)));
 
 

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

@@ -6,7 +6,7 @@ use darkfi::util::serial::{SerialDecodable, SerialEncodable};
 
 
 pub type PrivmsgId = u64;
 pub type PrivmsgId = u64;
 
 
-pub type SeenMsgIds = Arc<Mutex<Vec<u64>>>;
+pub type SeenMsgIds = Arc<Mutex<AllocRingBuffer<u64>>>;
 
 
 pub type PrivmsgsBuffer = Arc<Mutex<AllocRingBuffer<Privmsg>>>;
 pub type PrivmsgsBuffer = Arc<Mutex<AllocRingBuffer<Privmsg>>>;