chia_protocol/
unfinished_header_block.rs1use chia_streamable_macro::streamable;
2use chia_traits::Streamable;
3
4use crate::{
5 Bytes, Bytes32, EndOfSubSlotBundle, Foliage, FoliageTransactionBlock,
6 RewardChainBlockUnfinished, VDFProof,
7};
8
9#[streamable]
10pub struct UnfinishedHeaderBlock {
11 finished_sub_slots: Vec<EndOfSubSlotBundle>,
14
15 reward_chain_block: RewardChainBlockUnfinished,
17
18 challenge_chain_sp_proof: Option<VDFProof>,
20
21 reward_chain_sp_proof: Option<VDFProof>,
23
24 foliage: Foliage,
26
27 foliage_transaction_block: Option<FoliageTransactionBlock>,
29
30 transactions_filter: Bytes,
32}
33
34impl UnfinishedHeaderBlock {
35 pub fn prev_header_hash(&self) -> Bytes32 {
36 self.foliage.prev_block_hash
37 }
38
39 pub fn header_hash(&self) -> Bytes32 {
40 self.foliage.hash().into()
41 }
42
43 pub fn total_iters(&self) -> u128 {
44 self.reward_chain_block.total_iters
45 }
46}
47
48#[cfg(feature = "py-bindings")]
49use chia_traits::ChiaToPython;
50
51#[cfg(feature = "py-bindings")]
52use pyo3::prelude::*;
53
54#[cfg(feature = "py-bindings")]
55#[pymethods]
56impl UnfinishedHeaderBlock {
57 #[getter]
58 #[pyo3(name = "prev_header_hash")]
59 fn py_prev_header_hash(&self) -> Bytes32 {
60 self.prev_header_hash()
61 }
62
63 #[getter]
64 #[pyo3(name = "header_hash")]
65 fn py_header_hash(&self) -> Bytes32 {
66 self.header_hash()
67 }
68
69 #[getter]
70 #[pyo3(name = "total_iters")]
71 fn py_total_iters<'a>(&self, py: Python<'a>) -> PyResult<Bound<'a, PyAny>> {
72 ChiaToPython::to_python(&self.total_iters(), py)
73 }
74}