diff --git a/sn_client/src/api.rs b/sn_client/src/api.rs index f69d4f00f8..297804da8e 100644 --- a/sn_client/src/api.rs +++ b/sn_client/src/api.rs @@ -281,8 +281,8 @@ impl Client { .await; let record = match maybe_record { Ok(r) => r, - Err(NetworkError::SplitRecord(map)) => { - return merge_split_register_records(address, &map) + Err(NetworkError::SplitRecord { result_map }) => { + return merge_split_register_records(address, &result_map) } Err(e) => { warn!("Failed to get record at {address:?} from the network: {e:?}"); @@ -442,19 +442,7 @@ impl Client { /// Verify if a `Register` is stored by expected nodes on the network. pub async fn verify_register_stored(&self, address: RegisterAddress) -> Result { info!("Verifying register: {address:?}"); - let key = NetworkAddress::from_register_address(address).to_record_key(); - let record = self - .network - .get_record_from_network(key, None, GetQuorum::All, false, Default::default()) - .await?; - - let header = RecordHeader::from_record(&record)?; - if let RecordKind::Register = header.kind { - let register = get_register_from_record(record)?; - Ok(register) - } else { - Err(ProtocolError::RecordKindMismatch(RecordKind::Register).into()) - } + self.get_signed_register_from_network(address).await } /// Send a `SpendCashNote` request to the network diff --git a/sn_networking/src/error.rs b/sn_networking/src/error.rs index 19d83ea453..b32d53856f 100644 --- a/sn_networking/src/error.rs +++ b/sn_networking/src/error.rs @@ -112,8 +112,11 @@ pub enum Error { #[error("Gossipsub subscribe Error: {0}")] GossipsubSubscriptionError(#[from] SubscriptionError), - #[error("Split Record: {0:?}")] - SplitRecord(HashMap)>), + // Avoid logging the whole `Record` content by accident + #[error("Split Record has {} different copies", result_map.len())] + SplitRecord { + result_map: HashMap)>, + }, #[error("Record header is incorrect")] InCorrectRecordHeader, diff --git a/sn_networking/src/event.rs b/sn_networking/src/event.rs index ac0c2828bb..b1f5cddfba 100644 --- a/sn_networking/src/event.rs +++ b/sn_networking/src/event.rs @@ -1025,7 +1025,7 @@ impl SwarmDriver { let _ = sender.send(result); } else { debug!("For record {pretty_key:?} task {query_id:?}, fetch completed with split record"); - let _ = sender.send(Err(Error::SplitRecord(result_map))); + let _ = sender.send(Err(Error::SplitRecord { result_map })); } } else { let _ = self diff --git a/sn_networking/src/lib.rs b/sn_networking/src/lib.rs index f6e0c0c63e..aa740e77e1 100644 --- a/sn_networking/src/lib.rs +++ b/sn_networking/src/lib.rs @@ -370,7 +370,8 @@ impl Network { warn!("No holder of record '{pretty_key:?}' found. Retrying the fetch ...",); } Err(error) => { - error!("{error:?}"); + error!("Getting record {pretty_key:?} attempts #{verification_attempts}/{total_attempts} , encountered {error:?}"); + if verification_attempts >= total_attempts { break; }