Skip to content

Commit

Permalink
Merge pull request #703 from AmineKhaldi/py_validate_clvm_and_signatu…
Browse files Browse the repository at this point in the history
…re_release_gil

CHIA-1344 Release the GIL when calling validate_clvm_and_signature in the python binding
  • Loading branch information
AmineKhaldi authored Sep 18, 2024
2 parents adfc667 + 1b67eb1 commit 598ff61
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions wheel/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,16 +422,19 @@ fn fast_forward_singleton<'p>(
#[pyo3(name = "validate_clvm_and_signature")]
#[allow(clippy::type_complexity)]
pub fn py_validate_clvm_and_signature(
py: Python<'_>,
new_spend: &SpendBundle,
max_cost: u64,
constants: &ConsensusConstants,
peak_height: u32,
) -> PyResult<(OwnedSpendBundleConditions, Vec<([u8; 32], GTElement)>, f32)> {
let (owned_conditions, additions, duration) =
validate_clvm_and_signature(new_spend, max_cost, constants, peak_height).map_err(|e| {
let (owned_conditions, additions, duration) = py
.allow_threads(|| validate_clvm_and_signature(new_spend, max_cost, constants, peak_height))
.map_err(|e| {
// cast validation error to int
let error_code: u32 = e.into();
PyErr::new::<PyTypeError, _>(error_code)
})?; // cast validation error to int
})?;
Ok((owned_conditions, additions, duration.as_secs_f32()))
}

Expand Down

0 comments on commit 598ff61

Please sign in to comment.