Skip to content

Commit

Permalink
change log level to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Shourya742 committed Nov 2, 2024
1 parent a828a85 commit f244cf7
Showing 1 changed file with 34 additions and 23 deletions.
57 changes: 34 additions & 23 deletions roles/jd-server/src/lib/job_declarator/message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl ParseClientJobDeclarationMessages for JobDeclaratorDownstream {
}
}

pub fn clear_declared_mining_job(
fn clear_declared_mining_job(

Check warning on line 229 in roles/jd-server/src/lib/job_declarator/message_handler.rs

View check run for this annotation

Codecov / codecov/patch

roles/jd-server/src/lib/job_declarator/message_handler.rs#L229

Added line #L229 was not covered by tests
old_mining_job: DeclareMiningJob,
new_mining_job: &DeclareMiningJob,
mempool: Arc<Mutex<JDsMempool>>,
Expand All @@ -241,39 +241,50 @@ pub fn clear_declared_mining_job(

let nonce = old_mining_job.tx_short_hash_nonce;

Check warning on line 242 in roles/jd-server/src/lib/job_declarator/message_handler.rs

View check run for this annotation

Codecov / codecov/patch

roles/jd-server/src/lib/job_declarator/message_handler.rs#L242

Added line #L242 was not covered by tests

let result = mempool.safe_lock(|mempool_| -> Result<(), Error> {
let short_ids_map = mempool_
.to_short_ids(nonce)
.ok_or(Error::JDSMissingTransactions)?;
let result = mempool
.safe_lock(|mempool_| -> Result<(), Error> {
let short_ids_map = mempool_
.to_short_ids(nonce)
.ok_or(Error::JDSMissingTransactions)?;

Check warning on line 248 in roles/jd-server/src/lib/job_declarator/message_handler.rs

View check run for this annotation

Codecov / codecov/patch

roles/jd-server/src/lib/job_declarator/message_handler.rs#L244-L248

Added lines #L244 - L248 were not covered by tests

for short_id in old_transactions {
if !new_transactions.contains(&short_id) {
if let Some(transaction_with_hash) = short_ids_map.get(short_id) {
for short_id in old_transactions

Check warning on line 250 in roles/jd-server/src/lib/job_declarator/message_handler.rs

View check run for this annotation

Codecov / codecov/patch

roles/jd-server/src/lib/job_declarator/message_handler.rs#L250

Added line #L250 was not covered by tests
.iter()
.filter(|&id| !new_transactions.contains(id))

Check warning on line 252 in roles/jd-server/src/lib/job_declarator/message_handler.rs

View check run for this annotation

Codecov / codecov/patch

roles/jd-server/src/lib/job_declarator/message_handler.rs#L252

Added line #L252 was not covered by tests
{
if let Some(transaction_with_hash) = short_ids_map.get(*short_id) {
let txid = transaction_with_hash.id;
match mempool_.mempool.get_mut(&txid) {

Check warning on line 256 in roles/jd-server/src/lib/job_declarator/message_handler.rs

View check run for this annotation

Codecov / codecov/patch

roles/jd-server/src/lib/job_declarator/message_handler.rs#L254-L256

Added lines #L254 - L256 were not covered by tests
Some(Some((transaction, counter))) => {
Some(Some((_transaction, counter))) => {
if *counter > 1 {
*counter -= 1;
info!("Fat transaction {:?} decreased mempool counter because job id {:?} was dropped", txid, old_mining_job.request_id);
debug!(

Check warning on line 260 in roles/jd-server/src/lib/job_declarator/message_handler.rs

View check run for this annotation

Codecov / codecov/patch

roles/jd-server/src/lib/job_declarator/message_handler.rs#L258-L260

Added lines #L258 - L260 were not covered by tests
"Fat transaction {:?} counter decremented; job id {:?} dropped",
txid, old_mining_job.request_id
);
} else {
mempool_.mempool.remove(&txid);
info!("Fat transaction {:?} in job with request id {:?} removed from mempool", txid, old_mining_job.request_id);
debug!(

Check warning on line 266 in roles/jd-server/src/lib/job_declarator/message_handler.rs

View check run for this annotation

Codecov / codecov/patch

roles/jd-server/src/lib/job_declarator/message_handler.rs#L266

Added line #L266 was not covered by tests
"Fat transaction {:?} with job id {:?} removed from mempool",
txid, old_mining_job.request_id
);
}
},
Some(None) => info!("Thin transaction {:?} in job with request id {:?} removed from mempool", txid, old_mining_job.request_id),
None => {},
}
Some(None) => debug!(

Check warning on line 272 in roles/jd-server/src/lib/job_declarator/message_handler.rs

View check run for this annotation

Codecov / codecov/patch

roles/jd-server/src/lib/job_declarator/message_handler.rs#L272

Added line #L272 was not covered by tests
"Thin transaction {:?} with job id {:?} removed from mempool",
txid, old_mining_job.request_id
),
None => {}
}
} else {
debug!("Transaction with short id {:?} not found in mempool while clearing old jobs", short_id);
debug!(

Check warning on line 279 in roles/jd-server/src/lib/job_declarator/message_handler.rs

View check run for this annotation

Codecov / codecov/patch

roles/jd-server/src/lib/job_declarator/message_handler.rs#L279

Added line #L279 was not covered by tests
"Transaction with short id {:?} not found in mempool for old jobs",
short_id
);
}
}
}
Ok(())
});

if let Err(err) = result {
return Err(Error::PoisonLock(err.to_string()));
}
Ok(())

Check warning on line 285 in roles/jd-server/src/lib/job_declarator/message_handler.rs

View check run for this annotation

Codecov / codecov/patch

roles/jd-server/src/lib/job_declarator/message_handler.rs#L285

Added line #L285 was not covered by tests
})
.map_err(|e| Error::PoisonLock(e.to_string()))?;

Check warning on line 287 in roles/jd-server/src/lib/job_declarator/message_handler.rs

View check run for this annotation

Codecov / codecov/patch

roles/jd-server/src/lib/job_declarator/message_handler.rs#L287

Added line #L287 was not covered by tests

Ok(())
result.map_err(|err| Error::PoisonLock(err.to_string()))

Check warning on line 289 in roles/jd-server/src/lib/job_declarator/message_handler.rs

View check run for this annotation

Codecov / codecov/patch

roles/jd-server/src/lib/job_declarator/message_handler.rs#L289

Added line #L289 was not covered by tests
}

0 comments on commit f244cf7

Please sign in to comment.