Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node: use announcer's timestamp in project inventory
Slack Coder committed 3 years ago
commit 186eb42145bfe40e384c2d20d0c4ba48fd9395c0
parent a496eeb84da629a6710080963bdfebbb8c65d6ef
1 file changed +10 -7
modified radicle-node/src/service.rs
@@ -639,7 +639,9 @@ where
                    return Ok(false);
                }

-
                if let Err(err) = self.process_inventory(&message.inventory, *announcer) {
+
                if let Err(err) =
+
                    self.process_inventory(&message.inventory, *announcer, &message.timestamp)
+
                {
                    error!("Error processing inventory from {}: {}", announcer, err);

                    if let Error::Fetch(storage::FetchError::Verify(err)) = err {
@@ -872,14 +874,15 @@ where
    }

    /// Process a peer inventory announcement by updating our routing table.
-
    fn process_inventory(&mut self, inventory: &Inventory, from: NodeId) -> Result<(), Error> {
+
    fn process_inventory(
+
        &mut self,
+
        inventory: &Inventory,
+
        from: NodeId,
+
        timestamp: &Timestamp,
+
    ) -> Result<(), Error> {
        for proj_id in inventory {
            // TODO: Fire an event on routing update.
-
            // FIXME: The timestamp we insert should be the announcement timestamp.
-
            if self
-
                .routing
-
                .insert(*proj_id, from, self.clock.timestamp())?
-
                && self.config.is_tracking(proj_id)
+
            if self.routing.insert(*proj_id, from, *timestamp)? && self.config.is_tracking(proj_id)
            {
                log::info!("Routing table updated for {} with seed {}", proj_id, from);
            }