From 131bca593245a46feaa7c5d444f3e9dda1a2ebbd Mon Sep 17 00:00:00 2001 From: plebhash Date: Mon, 1 Jul 2024 11:44:25 -0300 Subject: [PATCH] avoid JDS dropping connection on SubmitSolution with missing txs this is the actual fix for #912 --- roles/jd-server/src/lib/job_declarator/mod.rs | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/roles/jd-server/src/lib/job_declarator/mod.rs b/roles/jd-server/src/lib/job_declarator/mod.rs index 34d9e66de4..4e4dad99c2 100644 --- a/roles/jd-server/src/lib/job_declarator/mod.rs +++ b/roles/jd-server/src/lib/job_declarator/mod.rs @@ -280,23 +280,21 @@ impl JobDeclaratorDownstream { match Self::collect_txs_in_job(self_mutex.clone()) { Ok(_) => { info!("All transactions in downstream job are recognized correctly by the JD Server"); - let hexdata = - match JobDeclaratorDownstream::get_block_hex( - self_mutex.clone(), - message, - ) { - Ok(inner) => inner, - Err(e) => { - error!( + match JobDeclaratorDownstream::get_block_hex( + self_mutex.clone(), + message, + ) { + Ok(hexdata) => { + let _ = + new_block_sender.send(hexdata).await; + } + Err(e) => { + error!( "Received solution but encountered error: {:?}", e ); - recv.close(); - //TODO should we brake it? - break; - } - }; - let _ = new_block_sender.send(hexdata).await; + } + }; } Err(error) => { error!("Missing transactions: {:?}", error); @@ -316,22 +314,20 @@ impl JobDeclaratorDownstream { .unwrap(); tokio::select! { _ = JDsMempool::add_tx_data_to_mempool(mempool, retrieve_transactions) => { - let hexdata = match JobDeclaratorDownstream::get_block_hex( + match JobDeclaratorDownstream::get_block_hex( self_mutex.clone(), message.clone(), ) { - Ok(inner) => inner, + Ok(hexdata) => { + let _ = new_block_sender.send(hexdata).await; + }, Err(e) => { error!( "Error retrieving transactions: {:?}", e ); - recv.close(); - //TODO should we brake it? - break; } }; - let _ = new_block_sender.send(hexdata).await; } _ = tokio::time::sleep(Duration::from_secs(60)) => {} };