node: Don't fetch if only our own remote

Skip the fetch from announcement if the announcement only contains our
own remote.
This commit is contained in:
cloudhead 2024-03-31 23:34:44 +02:00
parent 6744ffc325
commit fd4f5fff7d
No known key found for this signature in database
1 changed files with 13 additions and 7 deletions

View File

@ -1436,10 +1436,6 @@ where
info!(target: "service", "Routing table updated for {} with seed {announcer}", message.rid);
}
}
let Some(refs) = NonEmpty::from_vec(message.refs.to_vec()) else {
debug!(target: "service", "Skipping fetch, empty refs announcement for {}", message.rid);
return Ok(false);
};
// Update sync status of announcer for this repo.
if let Some(refs) = message.refs.iter().find(|r| &r.remote == self.nid()) {
@ -1468,7 +1464,6 @@ where
}
}
}
let repo_entry = self.policies.seed_policy(&message.rid).expect(
"Service::handle_announcement: error accessing repo seeding configuration",
);
@ -1491,9 +1486,20 @@ where
);
return Ok(relay);
};
// Finally, if there's anything to fetch, we fetch it from the remote.
self.fetch_refs_at(message.rid, remote.id, refs, FETCH_TIMEOUT, None);
// Finally, if there's anything to fetch, we fetch it from the remote.
if let Some(refs) = NonEmpty::from_vec(
message
.refs
.iter()
.filter(|r| r.remote != self.node_id()) // Don't fetch our own refs.
.cloned()
.collect(),
) {
self.fetch_refs_at(message.rid, remote.id, refs, FETCH_TIMEOUT, None);
} else {
debug!(target: "service", "Skipping fetch, no remote refs in announcement for {}", message.rid);
}
return Ok(relay);
}
AnnouncementMessage::Node(