@@ -1224,17 +1224,35 @@ where
1224
1224
self . utp_listener_tx
1225
1225
. send ( utp_request) . map_err ( |err| anyhow ! ( "Unable to send Connect request to UtpListener when processing ACCEPT message: {err}" ) ) ?;
1226
1226
1227
- let content_items = self . provide_requested_content ( & response, content_keys_offered) ?;
1228
-
1229
- let content_payload = ContentPayloadList :: new ( content_items)
1230
- . map_err ( |err| anyhow ! ( "Unable to build content payload: {err:?}" ) ) ?;
1227
+ let storage = Arc :: clone ( & self . storage ) ;
1228
+ let response_clone = response. clone ( ) ;
1231
1229
1232
1230
tokio:: spawn ( async move {
1233
1231
let mut conn = rx. await . unwrap ( ) ;
1234
1232
// Handle STATE packet for SYN
1235
1233
let mut buf = [ 0 ; BUF_SIZE ] ;
1236
1234
conn. recv ( & mut buf) . await . unwrap ( ) ;
1237
1235
1236
+ let content_items = match Self :: provide_requested_content (
1237
+ storage,
1238
+ & response_clone,
1239
+ content_keys_offered,
1240
+ ) {
1241
+ Ok ( val) => val,
1242
+ Err ( msg) => {
1243
+ warn ! ( "Unable to provide requested content for acceptor: {msg:?}" ) ;
1244
+ return ;
1245
+ }
1246
+ } ;
1247
+
1248
+ let content_payload = match ContentPayloadList :: new ( content_items) {
1249
+ Ok ( val) => val,
1250
+ Err ( msg) => {
1251
+ warn ! ( "Unable to build content payload: {msg:?}" ) ;
1252
+ return ;
1253
+ }
1254
+ } ;
1255
+
1238
1256
// send the content to the acceptor over a uTP stream
1239
1257
if let Err ( err) = conn. send_to ( & content_payload. as_ssz_bytes ( ) ) . await {
1240
1258
warn ! ( "Error sending content {err}" ) ;
@@ -1456,7 +1474,7 @@ where
1456
1474
1457
1475
/// Provide the requested content key and content value for the acceptor
1458
1476
fn provide_requested_content (
1459
- & self ,
1477
+ storage : Arc < RwLock < PortalStorage > > ,
1460
1478
accept_message : & Accept ,
1461
1479
content_keys_offered : Vec < TContentKey > ,
1462
1480
) -> anyhow:: Result < Vec < ByteList > > {
@@ -1469,7 +1487,7 @@ where
1469
1487
. zip ( content_keys_offered. iter ( ) )
1470
1488
{
1471
1489
if i == true {
1472
- match self . storage . read ( ) . get ( key) {
1490
+ match storage. read ( ) . get ( key) {
1473
1491
Ok ( content) => match content {
1474
1492
Some ( content) => content_items. push ( content. into ( ) ) ,
1475
1493
None => return Err ( anyhow ! ( "Unable to read offered content!" ) ) ,
0 commit comments