@@ -925,7 +925,17 @@ impl<
925
925
match response {
926
926
Response :: Pong ( pong) => self . process_pong ( pong, source) ,
927
927
Response :: Nodes ( nodes) => self . process_nodes ( nodes, source) ,
928
- Response :: Content ( content) => self . process_content ( content, source, request) . await ,
928
+ Response :: Content ( content) => {
929
+ let find_content_request = match request {
930
+ Request :: FindContent ( find_content) => find_content,
931
+ _ => {
932
+ error ! ( "Unable to process received content: Invalid request message." ) ;
933
+ return ;
934
+ }
935
+ } ;
936
+ self . process_content ( content, source, find_content_request)
937
+ . await
938
+ }
929
939
_ => { }
930
940
}
931
941
}
@@ -973,7 +983,7 @@ impl<
973
983
}
974
984
975
985
/// Processes a Content response.
976
- async fn process_content ( & mut self , content : Content , source : Enr , request : Request ) {
986
+ async fn process_content ( & mut self , content : Content , source : Enr , request : FindContent ) {
977
987
debug ! (
978
988
"[{:?}] Processing Content response from node. Node: {}" ,
979
989
self . protocol,
@@ -990,15 +1000,8 @@ impl<
990
1000
}
991
1001
}
992
1002
993
- async fn process_received_content ( & mut self , content : ByteList , request : Request ) {
994
- let find_content = match request {
995
- Request :: FindContent ( find_content) => find_content,
996
- _ => {
997
- error ! ( "Unable to process received content: Invalid request message." ) ;
998
- return ;
999
- }
1000
- } ;
1001
- let content_key = match TContentKey :: try_from ( find_content. content_key ) {
1003
+ async fn process_received_content ( & mut self , content : ByteList , request : FindContent ) {
1004
+ let content_key = match TContentKey :: try_from ( request. content_key ) {
1002
1005
Ok ( val) => val,
1003
1006
Err ( _) => {
1004
1007
error ! ( "Unable to process received content: Invalid content key." ) ;
@@ -1011,16 +1014,16 @@ impl<
1011
1014
. await
1012
1015
{
1013
1016
Ok ( _) => ( ) ,
1014
- Err ( _ ) => {
1015
- error ! ( "Unable to validate received content. " ) ;
1017
+ Err ( msg ) => {
1018
+ error ! ( "Unable to validate received content: {msg:?} " ) ;
1016
1019
return ;
1017
1020
}
1018
1021
}
1019
1022
match self . storage . read ( ) . should_store ( & content_key) {
1020
1023
Ok ( should_store) => match should_store {
1021
1024
true => match self . storage . write ( ) . store ( & content_key, & content. into ( ) ) {
1022
1025
Ok ( _) => ( ) ,
1023
- Err ( msg) => error ! ( "{}" , format! ( " Content received, but not stored: {msg}") ) ,
1026
+ Err ( msg) => error ! ( "Content received, but not stored: {msg}" ) ,
1024
1027
} ,
1025
1028
false => debug ! (
1026
1029
"Content received, but not stored: Content is already stored or its distance falls outside current radius."
@@ -1329,7 +1332,7 @@ mod tests {
1329
1332
content_key:: IdentityContentKey , messages:: PortalnetConfig , metric:: XorMetric ,
1330
1333
} ,
1331
1334
} ,
1332
- types:: validation:: IdentityValidator ,
1335
+ types:: validation:: MockValidator ,
1333
1336
utils:: node_id:: generate_random_remote_enr,
1334
1337
} ;
1335
1338
@@ -1344,7 +1347,7 @@ mod tests {
1344
1347
} ;
1345
1348
}
1346
1349
1347
- fn build_service ( ) -> OverlayService < IdentityContentKey , XorMetric , IdentityValidator > {
1350
+ fn build_service ( ) -> OverlayService < IdentityContentKey , XorMetric , MockValidator > {
1348
1351
let portal_config = PortalnetConfig {
1349
1352
no_stun : true ,
1350
1353
..Default :: default ( )
@@ -1375,7 +1378,7 @@ mod tests {
1375
1378
let ( request_tx, request_rx) = mpsc:: unbounded_channel ( ) ;
1376
1379
let ( response_tx, response_rx) = mpsc:: unbounded_channel ( ) ;
1377
1380
let metrics = None ;
1378
- let validator = IdentityValidator { } ;
1381
+ let validator = MockValidator { } ;
1379
1382
1380
1383
OverlayService {
1381
1384
discovery,
0 commit comments