Просмотр исходного кода

bin/ircd: little clean up & fix typo

ghassmo 3 лет назад
Родитель
Сommit
0a3d6b7ef0
1 измененных файлов с 10 добавлено и 9 удалено
  1. 10 9
      bin/ircd/src/mvc.rs

+ 10 - 9
bin/ircd/src/mvc.rs

@@ -192,7 +192,7 @@ impl Model {
         let head = self.find_head();
         let head = self.find_head();
         let leaves = self.find_leaves();
         let leaves = self.find_leaves();
 
 
-        // find the common ancestor between for each leaf and the head event
+        // find the common ancestor for each leaf and the head event
         let mut ancestors = vec![];
         let mut ancestors = vec![];
         for leaf in leaves {
         for leaf in leaves {
             if leaf == head {
             if leaf == head {
@@ -210,9 +210,10 @@ impl Model {
 
 
         // set the new root
         // set the new root
         if let Some(ancestor) = highest_ancestor {
         if let Some(ancestor) = highest_ancestor {
-            // the ancestor must have at least height > 10
+            // TODO change this number 
+            // the ancestor must have at least height > 300
             let ancestor_height = self.find_height(&self.current_root, ancestor).unwrap();
             let ancestor_height = self.find_height(&self.current_root, ancestor).unwrap();
-            if ancestor_height < 10 {
+            if ancestor_height < 300 {
                 return
                 return
             }
             }
 
 
@@ -311,22 +312,22 @@ impl Model {
         depth
         depth
     }
     }
 
 
-    fn find_height(&self, parent: &EventId, child_id: &EventId) -> Option<u32> {
+    fn find_height(&self, node: &EventId, child_id: &EventId) -> Option<u32> {
         let mut height = 0;
         let mut height = 0;
 
 
-        if parent == child_id {
+        if node == child_id {
             return Some(height)
             return Some(height)
         }
         }
 
 
         height += 1;
         height += 1;
 
 
-        let parent_children = &self.event_map.get(parent).unwrap().children;
-        if parent_children.is_empty() {
+        let children = &self.event_map.get(node).unwrap().children;
+        if children.is_empty() {
             return None
             return None
         }
         }
 
 
-        for parent_child in parent_children.iter() {
-            if let Some(h) = self.find_height(parent_child, child_id) {
+        for child in children.iter() {
+            if let Some(h) = self.find_height(child, child_id) {
                 return Some(height + h)
                 return Some(height + h)
             }
             }
         }
         }