Jelajahi Sumber

script/evgrd: fetch successors of requested tips

dasman 1 tahun lalu
induk
melakukan
15c02253a8
2 mengubah file dengan 6 tambahan dan 10 penghapusan
  1. 5 9
      script/evgrd/bin/evgrd.rs
  2. 1 1
      script/evgrd/src/lib.rs

+ 5 - 9
script/evgrd/bin/evgrd.rs

@@ -202,19 +202,15 @@ async fn handle_connect(
 
                 let fetchevs = FetchEventsMessage::decode_async(&mut stream).await?;
                 info!(target: "evgrd", "Fetching events {fetchevs:?}");
-                // Now do your thing with the daemon and get missing tips
+                let events = daemon.event_graph.fetch_successors_of(fetchevs.unref_tips).await?;
 
-                // Then send them like this:
-
-                // for ev in evs {
-                //    MSG_EVENT.encode_async(&mut stream).await?;
-                //    ev.encode_async(&mut stream).await?;
-                // }
+                for event in events {
+                   MSG_EVENT.encode_async(&mut stream).await?;
+                   event.encode_async(&mut stream).await?;
+                }
             }
         }
     }
-
-    Ok(())
 }
 
 async_daemonize!(realmain);

+ 1 - 1
script/evgrd/src/lib.rs

@@ -47,7 +47,7 @@ impl VersionMessage {
 
 #[derive(Debug, Clone, SerialEncodable, SerialDecodable)]
 pub struct FetchEventsMessage {
-    unref_tips: Vec<(u64, blake3::Hash)>,
+    pub unref_tips: Vec<(u64, blake3::Hash)>,
 }
 
 impl FetchEventsMessage {