Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Do not leak records #13086

Merged
merged 1 commit into from
Jan 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions client/network/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,8 @@ impl NetworkBehaviour for DiscoveryBehaviour {
}
}

// Will be removed below when we receive
// `FinishedWithNoAdditionalRecord`.
self.records_to_publish.insert(id, r.record.clone());

DiscoveryOut::ValueFound(
Expand All @@ -726,13 +728,14 @@ impl NetworkBehaviour for DiscoveryBehaviour {
Ok(GetRecordOk::FinishedWithNoAdditionalRecord {
cache_candidates,
}) => {
if cache_candidates.is_empty() {
continue
}

// Put the record to the `cache_candidates` that are nearest to the
// record key from our point of view of the network.
// We always need to remove the record to not leak any data!
if let Some(record) = self.records_to_publish.remove(&id) {
if cache_candidates.is_empty() {
continue
}

// Put the record to the `cache_candidates` that are nearest to
// the record key from our point of view of the network.
if let Some(kad) = self.kademlia.as_mut() {
kad.put_record_to(
record,
Expand Down