diff --git a/ant-networking/src/error.rs b/ant-networking/src/error.rs index ff142a6bda..c9444d1f59 100644 --- a/ant-networking/src/error.rs +++ b/ant-networking/src/error.rs @@ -134,6 +134,9 @@ pub enum NetworkError { NoGraphEntryFoundInsideRecord(GraphEntryAddress), // ---------- Store Error + #[error("Not Enough Peers for Store Cost Request")] + NotEnoughPeersForStoreCostRequest, + #[error("No Store Cost Responses")] NoStoreCostResponses, diff --git a/ant-networking/src/lib.rs b/ant-networking/src/lib.rs index 1f7f52b237..620017fcf6 100644 --- a/ant-networking/src/lib.rs +++ b/ant-networking/src/lib.rs @@ -397,7 +397,7 @@ impl Network { if close_nodes.is_empty() { error!("Can't get store_cost of {record_address:?}, as all close_nodes are ignored"); - return Err(NetworkError::NoStoreCostResponses); + return Err(NetworkError::NotEnoughPeersForStoreCostRequest); } // Client shall decide whether to carry out storage verification or not. @@ -416,6 +416,8 @@ impl Network { let mut peer_already_have_it = 0; let enough_peers_already_have_it = close_nodes.len() / 2; + let mut peers_returned_error = 0; + // loop over responses let mut all_quotes = vec![]; let mut quotes_to_pay = vec![]; @@ -456,13 +458,23 @@ impl Network { } Err(err) => { error!("Got an error while requesting quote from peer {peer:?}: {err}"); + peers_returned_error += 1; } _ => { error!("Got an unexpected response while requesting quote from peer {peer:?}: {response:?}"); + peers_returned_error += 1; } } } + if quotes_to_pay.is_empty() { + error!( + "Could not fetch any quotes. {} peers returned an error.", + peers_returned_error + ); + return Err(NetworkError::NoStoreCostResponses); + } + Ok(quotes_to_pay) }