diff --git a/crates/chia-datalayer/src/merkle.rs b/crates/chia-datalayer/src/merkle.rs index 6b7b8fba9..f26818e3a 100644 --- a/crates/chia-datalayer/src/merkle.rs +++ b/crates/chia-datalayer/src/merkle.rs @@ -229,6 +229,25 @@ impl InternalNode { } } +#[cfg(feature = "py-bindings")] +#[pymethods] +impl InternalNode { + #[new] + pub fn py_init( + parent: Parent, + hash: Hash, + left: TreeIndex, + right: TreeIndex, + ) -> PyResult { + Ok(Self { + parent, + hash, + left, + right, + }) + } +} + #[cfg_attr(feature = "py-bindings", pyclass(get_all))] #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, Streamable)] pub struct LeafNode { @@ -238,6 +257,20 @@ pub struct LeafNode { pub value: KvId, } +#[cfg(feature = "py-bindings")] +#[pymethods] +impl LeafNode { + #[new] + pub fn py_init(parent: Parent, hash: Hash, key: KvId, value: KvId) -> PyResult { + Ok(Self { + parent, + hash, + key, + value, + }) + } +} + #[derive(Clone, Debug, PartialEq, Eq)] pub enum Node { Internal(InternalNode), diff --git a/wheel/python/chia_rs/datalayer.pyi b/wheel/python/chia_rs/datalayer.pyi index 729a3ab16..9b6464396 100644 --- a/wheel/python/chia_rs/datalayer.pyi +++ b/wheel/python/chia_rs/datalayer.pyi @@ -12,6 +12,8 @@ METADATA_SIZE: int @final class InternalNode: + def __init__(self, parent: Optional[uint32], hash: bytes32, left: uint32, right: uint32) -> None: ... + @property def parent(self) -> Optional[uint32]: ... @property @@ -25,6 +27,8 @@ class InternalNode: @final class LeafNode: + def __init__(self, parent: Optional[uint32], hash: bytes32, key: int64, value: int64) -> None: ... + @property def parent(self) -> Optional[uint32]: ... @property