Skip to content

Commit

Permalink
feat(client): carry out quote self validation
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi authored and jacderida committed Sep 18, 2024
1 parent 570a11c commit dbaeb2c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sn_networking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ impl Network {
let mut all_costs = vec![];
let mut all_quotes = vec![];
for response in responses.into_values().flatten() {
debug!(
info!(
"StoreCostReq for {record_address:?} received response: {:?}",
response
);
Expand All @@ -376,6 +376,14 @@ impl Network {
payment_address,
peer_address,
}) => {
// Check the quote itself is valid.
if quote.cost.as_nano()
!= calculate_cost_for_records(quote.quoting_metrics.close_records_stored)
{
warn!("Received invalid quote from {peer_address:?}, {quote:?}");
continue;
}

all_costs.push((peer_address.clone(), payment_address, quote.clone()));
all_quotes.push((peer_address, quote));
}
Expand Down

0 comments on commit dbaeb2c

Please sign in to comment.