|
1 | 1 | use std::{
|
2 | 2 | collections::HashMap,
|
3 | 3 | fmt,
|
| 4 | + fmt::Debug, |
4 | 5 | marker::{PhantomData, Sync},
|
5 | 6 | sync::Arc,
|
6 | 7 | task::Poll,
|
@@ -277,6 +278,8 @@ impl<
|
277 | 278 | TMetric: Metric + Send,
|
278 | 279 | TValidator: 'static + Validator<TContentKey> + Send,
|
279 | 280 | > OverlayService<TContentKey, TMetric, TValidator>
|
| 281 | +where |
| 282 | + <TContentKey as TryFrom<Vec<u8>>>::Error: Debug, |
280 | 283 | {
|
281 | 284 | /// Spawns the overlay network service.
|
282 | 285 | ///
|
@@ -971,32 +974,31 @@ impl<
|
971 | 974 | async fn process_received_content(&mut self, content: ByteList, request: FindContent) {
|
972 | 975 | let content_key = match TContentKey::try_from(request.content_key) {
|
973 | 976 | Ok(val) => val,
|
974 |
| - Err(_) => { |
975 |
| - error!("Unable to process received content: Invalid content key."); |
| 977 | + Err(msg) => { |
| 978 | + error!("Unable to process received content: Invalid content key: {msg:?}"); |
976 | 979 | return;
|
977 | 980 | }
|
978 | 981 | };
|
979 |
| - match self |
| 982 | + if let Err(err) = self |
980 | 983 | .validator
|
981 | 984 | .validate_content(&content_key, &content)
|
982 | 985 | .await
|
983 | 986 | {
|
984 |
| - Ok(_) => (), |
985 |
| - Err(msg) => { |
986 |
| - error!("Unable to validate received content: {msg:?}"); |
987 |
| - return; |
988 |
| - } |
989 |
| - } |
| 987 | + error!("Unable to validate received content: {err:?}"); |
| 988 | + return; |
| 989 | + }; |
990 | 990 | match self.storage.read().should_store(&content_key) {
|
991 |
| - Ok(should_store) => match should_store { |
992 |
| - true => match self.storage.write().store(&content_key, &content.into()) { |
993 |
| - Ok(_) => (), |
994 |
| - Err(msg) => error!("Content received, but not stored: {msg}"), |
995 |
| - }, |
996 |
| - false => debug!( |
997 |
| - "Content received, but not stored: Content is already stored or its distance falls outside current radius." |
998 |
| - ), |
999 |
| - }, |
| 991 | + Ok(should_store) => { |
| 992 | + if should_store { |
| 993 | + if let Err(err) = self.storage.write().store(&content_key, &content.into()) { |
| 994 | + error!("Content received, but not stored: {err}") |
| 995 | + } |
| 996 | + } else { |
| 997 | + debug!( |
| 998 | + "Content received, but not stored: Content is already stored or its distance falls outside current radius." |
| 999 | + ) |
| 1000 | + } |
| 1001 | + } |
1000 | 1002 | Err(_) => {
|
1001 | 1003 | error!("Content received, but not stored: Error communicating with db.");
|
1002 | 1004 | }
|
|
0 commit comments