Ver Fonte

wallet: timestamp correction time was 10ms, should be 10s

darkfi há 1 ano atrás
pai
commit
878c11f563
2 ficheiros alterados com 12 adições e 11 exclusões
  1. 5 4
      bin/darkwallet/src/darkirc2.rs
  2. 7 7
      bin/darkwallet/src/ui/editbox.rs

+ 5 - 4
bin/darkwallet/src/darkirc2.rs

@@ -65,7 +65,7 @@ const CHANNEL: &str = "#random";
 
 /// Due to drift between different machine's clocks, if the message timestamp is recent
 /// then we will just correct it to the current time so messages appear sequential in the UI.
-const RECENT_TIME_DIST: u64 = 10;
+const RECENT_TIME_DIST: u64 = 10_000;
 
 #[derive(Clone, Debug, SerialEncodable, SerialDecodable)]
 pub struct Privmsg {
@@ -324,11 +324,11 @@ impl LocalDarkIRC {
             }
         };
 
-        debug!(target: "darkirc", "privmsg: {privmsg:?}");
         let mut timest = ev.timestamp;
         if timest < 6047051717 {
             timest *= 1000;
         }
+        debug!(target: "darkirc", "Recv privmsg: <{timest}> {privmsg:?}");
 
         if privmsg.channel != CHANNEL {
             return Ok(())
@@ -337,6 +337,7 @@ impl LocalDarkIRC {
         // This is a hack to make messages appear sequentially in the UI
         let now_timest = UNIX_EPOCH.elapsed().unwrap().as_millis() as u64;
         if timest.abs_diff(now_timest) < RECENT_TIME_DIST {
+            debug!(target: "darkirc", "Applied timestamp correction: <{timest}> => <{now_timest}>");
             timest = now_timest;
         }
 
@@ -359,9 +360,9 @@ impl LocalDarkIRC {
         self.chatview_scroll.set(0.);
 
         // Send text to channel
-        debug!(target: "darkirc", "Sending privmsg: {text}");
-        let msg = Privmsg::new(CHANNEL.to_string(), "anon".to_string(), text);
         let timestamp = UNIX_EPOCH.elapsed().unwrap().as_millis() as u64;
+        debug!(target: "darkirc", "Sending privmsg: <{timestamp}> {text}");
+        let msg = Privmsg::new(CHANNEL.to_string(), "anon".to_string(), text);
 
         self.send_sender.send((timestamp, msg)).await.unwrap();
     }

+ 7 - 7
bin/darkwallet/src/ui/editbox.rs

@@ -367,8 +367,8 @@ impl EditBox {
         let cursor_pos = self.cursor_pos.get() as usize;
         let cursor_color = self.cursor_color.get();
         let debug = self.debug.get();
-        debug!(target: "ui::editbox", "Rendering text '{text}' clip={clip:?}");
-        debug!(target: "ui::editbox", "    cursor_pos={cursor_pos}, is_focused={is_focused}");
+        //debug!(target: "ui::editbox", "Rendering text '{text}' clip={clip:?}");
+        //debug!(target: "ui::editbox", "    cursor_pos={cursor_pos}, is_focused={is_focused}");
 
         let glyphs = self.glyphs.lock().unwrap().clone();
         let atlas = text::make_texture_atlas(&self.render_api, &glyphs);
@@ -1099,7 +1099,7 @@ impl EditBox {
             // We're finished with these so clean up.
             if let Some(old) = text_mesh {
                 if let Some(texture) = old.texture {
-                    debug!(target: "ui::editbox", "{:?}: freeing old texture", self.node());
+                    //debug!(target: "ui::editbox", "{:?}: freeing old texture", self.node());
                     freed.textures.push(texture);
                 }
                 freed.buffers.push(old.vertex_buffer);
@@ -1114,7 +1114,7 @@ impl EditBox {
         // We're finished with these so clean up.
         if let Some(old) = old_text_mesh {
             if let Some(texture) = old.texture {
-                debug!(target: "ui::editbox", "{:?}: freeing old texture", self.node());
+                //debug!(target: "ui::editbox", "{:?}: freeing old texture", self.node());
                 freed.textures.push(texture);
             }
             freed.buffers.push(old.vertex_buffer);
@@ -1197,7 +1197,7 @@ impl UIObject for EditBox {
             let mut repeater = self.key_repeat.lock().unwrap();
             repeater.key_down(PressedKey::Char(key), repeat)
         };
-        debug!(target: "ui::editbox", "Key {:?} has {} actions", key, actions);
+        //debug!(target: "ui::editbox", "Key {:?} has {} actions", key, actions);
         for _ in 0..actions {
             self.insert_char(key).await;
         }
@@ -1220,9 +1220,9 @@ impl UIObject for EditBox {
             repeater.key_down(PressedKey::Key(key), repeat)
         };
         // Suppress noisy message
-        if actions > 0 {
+        /*if actions > 0 {
             debug!(target: "ui::editbox", "Key {:?} has {} actions", key, actions);
-        }
+        }*/
         for _ in 0..actions {
             self.handle_key(&key, &mods).await;
         }