Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move all use to the top in datalayer #894

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions crates/chia-datalayer/src/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
use pyo3::{
buffer::PyBuffer,
exceptions::PyValueError,
prelude::*,
pyclass, pymethods,
types::{PyDict, PyInt},
types::{PyDict, PyDictMethods, PyInt, PyListMethods},
Bound, FromPyObject, IntoPyObject, PyAny, PyErr, PyResult, Python,
};

Expand Down Expand Up @@ -96,7 +97,7 @@ macro_rules! create_errors {

#[cfg(feature = "py-bindings")]
pub mod python_exceptions {
use pyo3::prelude::*;
use super::*;

$(
pyo3::create_exception!(chia_rs.chia_rs.datalayer, $python_name, pyo3::exceptions::PyException);
Expand Down Expand Up @@ -1429,7 +1430,6 @@ impl MerkleBlob {

#[pyo3(name = "get_raw_node")]
pub fn py_get_raw_node(&mut self, index: &Bound<'_, PyInt>) -> PyResult<Node> {
use pyo3::prelude::PyAnyMethods;
let index = TreeIndex(index.extract::<u32>().or(Err(
python_exceptions::BlockIndexOutOfBoundsError::new_err(index.to_string()),
))?);
Expand All @@ -1450,7 +1450,6 @@ impl MerkleBlob {
let list = pyo3::types::PyList::empty(py);

for (index, node) in self.get_lineage_with_indexes(index)? {
use pyo3::types::PyListMethods;
list.append((index.into_pyobject(py)?, node.into_pyobject(py)?))?;
}

Expand All @@ -1462,7 +1461,6 @@ impl MerkleBlob {
let list = pyo3::types::PyList::empty(py);

for item in MerkleBlobParentFirstIterator::new(&self.blob) {
use pyo3::types::PyListMethods;
let (index, block) = item?;
list.append((index.into_pyobject(py)?, block.node.into_pyobject(py)?))?;
}
Expand Down Expand Up @@ -1523,7 +1521,6 @@ impl MerkleBlob {
let map = self.get_keys_values()?;
let dict = PyDict::new(py);
for (key, value) in map {
use pyo3::types::PyDictMethods;
dict.set_item(key, value)?;
}

Expand Down
Loading