Skip to content

Commit

Permalink
Release the GIL when calling validate_clvm_and_signature in the pytho…
Browse files Browse the repository at this point in the history
…n binding.
  • Loading branch information
AmineKhaldi committed Sep 6, 2024
1 parent ed7ece8 commit a039bc9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions wheel/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,17 +421,20 @@ fn fast_forward_singleton<'p>(
#[pyfunction]
#[pyo3(name = "validate_clvm_and_signature")]
#[allow(clippy::type_complexity)]
pub fn py_validate_clvm_and_signature(
pub fn py_validate_clvm_and_signature<'a>(
py: Python<'a>,
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 a039bc9

Please sign in to comment.