Przeglądaj źródła

event_graph: remove unused code

dasman 2 lat temu
rodzic
commit
faf8b80e36
3 zmienionych plików z 1 dodań i 116 usunięć
  1. 0 16
      src/event_graph/deg.rs
  2. 0 46
      src/event_graph/mod.rs
  3. 1 54
      src/event_graph/proto.rs

+ 0 - 16
src/event_graph/deg.rs

@@ -18,18 +18,6 @@
 
 use crate::util::time::NanoTimestamp;
 
-macro_rules! degev {
-      ($self:expr, $event_name:ident, $($code:tt)*) => {
-          {
-              if *$self.event_graph.deg_enabled.read().await {
-                  let event = DegEvent::$event_name(deg::$event_name $($code)*);
-                  $self.event_graph.deg_notify(event).await;
-              }
-          }
-      };
-  }
-pub(crate) use degev;
-
 #[derive(Clone, Debug)]
 pub struct MessageInfo {
     pub info: Vec<String>,
@@ -37,10 +25,6 @@ pub struct MessageInfo {
     pub time: NanoTimestamp,
 }
 
-// Needed by the degev!() macro
-pub type SendMessage = MessageInfo;
-pub type RecvMessage = MessageInfo;
-
 #[derive(Clone, Debug)]
 pub enum DegEvent {
     SendMessage(MessageInfo),

+ 0 - 46
src/event_graph/mod.rs

@@ -44,7 +44,6 @@ use crate::{
         sleep, timeout::timeout, StoppableTask, StoppableTaskPtr, Subscriber, SubscriberPtr,
         Subscription,
     },
-    util::time::NanoTimestamp,
     Error, Result,
 };
 
@@ -625,25 +624,6 @@ 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)
     }
 
@@ -856,32 +836,6 @@ impl EventGraph {
             .collect();
         let values = json_map([("dag", JsonValue::Object(json_graph))]);
 
-        // let u_tips = self.unreferenced_tips.read().await.clone();
-        // let u_tips_vals = u_tips
-        //     .into_values()
-        //     .map(|v| v.into_iter().map(|x| JsonValue::String(x.to_string())).collect::<Vec<_>>())
-        //     .collect::<Vec<_>>()
-        //     .concat();
-
-        // let b_ids = self
-        //     .broadcasted_ids
-        //     .read()
-        //     .await
-        //     .clone()
-        //     .into_iter()
-        //     .map(|id| JsonValue::String(id.to_string()))
-        //     .collect::<Vec<_>>();
-
-        // let values = json_map([
-        //     ("unreferenced_tips", JsonValue::Array(u_tips_vals)),
-        //     ("broadcasted_ids", JsonValue::Array(b_ids)),
-        //     ("synced", JsonValue::Boolean(*self.synced.read().await)),
-        //     (
-        //         "current_genesis",
-        //         JsonValue::String(self.current_genesis.read().await.clone().id().to_string()),
-        //     ),
-        // ]);
-
         let result = JsonValue::Object(HashMap::from([("eventgraph_info".to_string(), values)]));
 
         JsonResponse::new(result, id).into()

+ 1 - 54
src/event_graph/proto.rs

@@ -32,14 +32,7 @@ use log::{debug, error, trace, warn};
 use smol::Executor;
 
 use super::{Event, EventGraphPtr, NULL_ID};
-use crate::{
-    event_graph::{deg, deg::degev, DegEvent},
-    impl_p2p_message,
-    net::*,
-    system::timeout::timeout,
-    util::time::NanoTimestamp,
-    Error, Result,
-};
+use crate::{impl_p2p_message, net::*, system::timeout::timeout, Error, Result};
 
 /// Malicious behaviour threshold. If the threshold is reached, we will
 /// drop the peer from our P2P connection.
@@ -181,12 +174,6 @@ impl ProtocolEventGraph {
                 continue
             }
 
-            degev!(self, RecvMessage, {
-                info: vec![event_id.to_string()],
-                cmd: "EventPut".to_string(),
-                time: NanoTimestamp::current_time(),
-            });
-
             // We received an event. Check if we already have it in our DAG.
             // Check event is not older that current genesis event timestamp.
             // Also check if we have the event's parents. In the case we do
@@ -354,12 +341,6 @@ impl ProtocolEventGraph {
                 continue
             }
 
-            degev!(self, SendMessage, {
-                info: vec![event_id.to_string()],
-                cmd: "EventPut".to_string(),
-                time: NanoTimestamp::current_time(),
-            });
-
             // Relay the event to other peers.
             self.event_graph
                 .p2p
@@ -390,14 +371,6 @@ impl ProtocolEventGraph {
                 continue
             }
 
-            let info = event_ids.clone().into_iter().map(|x| x.to_string()).collect();
-
-            degev!(self, RecvMessage, {
-                info,
-                cmd: "EventReq".to_string(),
-                time: NanoTimestamp::current_time(),
-            });
-
             // We received an event request from somebody.
             // If we do have it, we will send it back to them as `EventRep`.
             // Otherwise, we'll stay quiet. An honest node should always have
@@ -469,14 +442,6 @@ impl ProtocolEventGraph {
             //bcast_ids.remove(&event_id);
             drop(bcast_ids);
 
-            let info = event_ids.into_iter().map(|x| x.to_string()).collect();
-
-            degev!(self, SendMessage, {
-                info,
-                cmd: "EventRep".to_string(),
-                time: NanoTimestamp::current_time(),
-            });
-
             // Reply with the event
             self.channel.send(&EventRep(events)).await?;
         }
@@ -488,11 +453,6 @@ impl ProtocolEventGraph {
     async fn handle_tip_req(self: Arc<Self>) -> Result<()> {
         loop {
             self.tip_req_sub.receive().await?;
-            degev!(self, RecvMessage, {
-                info: vec![],
-                cmd: "TipReq".to_string(),
-                time: NanoTimestamp::current_time(),
-            });
             trace!(
                 target: "event_graph::protocol::handle_tip_req()",
                 "Got TipReq [{}]", self.channel.address(),
@@ -520,19 +480,6 @@ impl ProtocolEventGraph {
             }
             drop(bcast_ids);
 
-            let info = layers
-                .clone()
-                .into_values()
-                .map(|v| v.into_iter().map(|id| id.to_string()).collect::<Vec<_>>())
-                .collect::<Vec<_>>()
-                .concat();
-
-            degev!(self, SendMessage, {
-                info,
-                cmd: "TipRep".to_string(),
-                time: NanoTimestamp::current_time(),
-            });
-
             self.channel.send(&TipRep(layers)).await?;
         }
     }