Skip to content

Commit

Permalink
Merge pull request #286 from Chia-Network/reward-chain-block-function
Browse files Browse the repository at this point in the history
RewardChainBlock get_unfinished()
  • Loading branch information
arvidn authored Oct 23, 2023
2 parents bf14e37 + 715bf3d commit 8f88296
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions chia-protocol/src/reward_chain_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use crate::ProofOfSpace;
use crate::VDFInfo;
use chia_bls::G2Element;

#[cfg(feature = "py-bindings")]
use pyo3::prelude::*;

streamable_struct! (RewardChainBlockUnfinished {
total_iters: u128,
signage_point_index: u8,
Expand Down Expand Up @@ -33,3 +36,19 @@ streamable_struct! (RewardChainBlock {
infused_challenge_chain_ip_vdf: Option<VDFInfo>, // Iff deficit < 16
is_transaction_block: bool,
});

#[cfg_attr(feature = "py-bindings", pymethods)]
impl RewardChainBlock {
pub fn get_unfinished(&self) -> RewardChainBlockUnfinished {
RewardChainBlockUnfinished {
total_iters: self.total_iters,
signage_point_index: self.signage_point_index,
pos_ss_cc_challenge_hash: self.pos_ss_cc_challenge_hash,
proof_of_space: self.proof_of_space.clone(),
challenge_chain_sp_vdf: self.challenge_chain_sp_vdf.clone(),
challenge_chain_sp_signature: self.challenge_chain_sp_signature.clone(),
reward_chain_sp_vdf: self.reward_chain_sp_vdf.clone(),
reward_chain_sp_signature: self.reward_chain_sp_signature.clone(),
}
}
}
1 change: 1 addition & 0 deletions wheel/chia_rs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,7 @@ class RewardChainBlock:
reward_chain_ip_vdf: VDFInfo
infused_challenge_chain_ip_vdf: Optional[VDFInfo]
is_transaction_block: bool
def get_unfinished(self) -> RewardChainBlockUnfinished: ...
def __init__(
self,
weight: int,
Expand Down
3 changes: 3 additions & 0 deletions wheel/generate_type_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ def parse_rust_source(filename: str) -> List[Tuple[str, List[str]]]:
"def get_included_reward_coins(self) -> List[Coin]: ...",
"def is_fully_compactified(self) -> bool: ...",
],
"RewardChainBlock": [
"def get_unfinished(self) -> RewardChainBlockUnfinished: ...",
],
}

classes = []
Expand Down

0 comments on commit 8f88296

Please sign in to comment.