node: use announcer's timestamp in project inventory

Address a FIXME in service.process_inventory() by using the announcer's
time instead of the service's.

Signed-off-by: Slack Coder <slackcoder@server.ky>
This commit is contained in:
Slack Coder 2022-11-03 09:23:32 -05:00
parent a496eeb84d
commit 186eb42145
1 changed files with 10 additions and 7 deletions

View File

@ -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);
}