فهرست منبع

bin/deg: updating unreferenced_tips on receiving new events

dasman 2 سال پیش
والد
کامیت
6d39951185
4فایلهای تغییر یافته به همراه32 افزوده شده و 14 حذف شده
  1. 0 2
      bin/deg/deg
  2. 10 7
      bin/deg/src/view.py
  3. 22 3
      src/event_graph/mod.rs
  4. 0 2
      src/event_graph/proto.rs

+ 0 - 2
bin/deg/deg

@@ -100,8 +100,6 @@ class Degview:
             if not values:
                 self.model.add_offline(info)
 
-            logging.debug(f"values: {values}")
-
             if 'result' in values:
                 result = values.get('result')
                 if 'eventgraph_info' in result:

+ 10 - 7
bin/deg/src/view.py

@@ -190,7 +190,15 @@ class View():
             info = self.model.nodes.get(node_name)
 
             if key in info:
-                ev = info.get(key)
+                ev = list(info.get(key))
+                if info['msgs']:
+                    msg = info['msgs'].get(node_name)
+                    for m in msg:
+                        event = m[1]
+                        event_info = m[2]
+                        msg = m[3]
+                        if event_info == "dag_insert" and event == "send":
+                            ev = msg
                 self.pile.contents.append((
                     urwid.Text(f" {ev}"),
                     self.pile.options()))
@@ -237,16 +245,13 @@ class View():
     def draw_events(self, nodes):
         for name, info in nodes:
             if bool(info) and name in self.known_nodes:
-                # info = info ['result']
                 self.fill_right_box()
-
-                # logging.debug(f"info: {info}")
                 
                 if 'unreferenced_tips' in info:
                         val = info['unreferenced_tips']
                         if not bool(val) or not val == None:
                             continue
-                        logging.debug(f"Refresh: unreferenced_tips online")
+                        logging.debug(f"Refresh: unreferenced_tips")
                         self.refresh = True
 
     async def update_view(self, evloop: asyncio.AbstractEventLoop,
@@ -268,6 +273,4 @@ class View():
             
             await self.display(nodes)
 
-            # logging.debug(f"nodes: {nodes}")
-
             self.draw_events(nodes)

+ 22 - 3
src/event_graph/mod.rs

@@ -44,6 +44,7 @@ use crate::{
         sleep, timeout::timeout, StoppableTask, StoppableTaskPtr, Subscriber, SubscriberPtr,
         Subscription,
     },
+    util::time::NanoTimestamp,
     Error, Result,
 };
 
@@ -107,10 +108,9 @@ pub struct EventGraph {
     days_rotation: u64,
     /// Flag signalling DAG has finished initial sync
     pub synced: RwLock<bool>,
-
     /// Enable graph debugging
     pub deg_enabled: RwLock<bool>,
-    /// The subscriber for which we can give dnet info over
+    /// The subscriber for which we can give deg info over
     deg_subscriber: SubscriberPtr<DegEvent>,
 }
 
@@ -625,6 +625,25 @@ impl EventGraph {
         drop(unreferenced_tips);
         drop(broadcasted_ids);
 
+        let info = self
+            .unreferenced_tips
+            .read()
+            .await
+            .clone()
+            .into_values()
+            .map(|v| v.into_iter().map(|id| id.to_string()).collect::<Vec<_>>())
+            .collect::<Vec<_>>()
+            .concat();
+
+        if *self.deg_enabled.read().await {
+            let event = DegEvent::SendMessage(deg::SendMessage {
+                info,
+                cmd: "dag_insert".to_string(),
+                time: NanoTimestamp::current_time(),
+            });
+            self.deg_notify(event).await;
+        };
+
         Ok(ids)
     }
 
@@ -808,7 +827,7 @@ impl EventGraph {
         warn!("[EVENTGRAPH] Graph debugging disabled!");
     }
 
-    /// Subscribe to dnet events
+    /// Subscribe to deg events
     pub async fn deg_subscribe(&self) -> Subscription<DegEvent> {
         self.deg_subscriber.clone().subscribe().await
     }

+ 0 - 2
src/event_graph/proto.rs

@@ -533,8 +533,6 @@ impl ProtocolEventGraph {
                 time: NanoTimestamp::current_time(),
             });
 
-            let _ = self.event_graph.eventgraph_info(1, tinyjson::JsonValue::Array(vec![])).await;
-
             self.channel.send(&TipRep(layers)).await?;
         }
     }