Skip to content
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
26 changes: 26 additions & 0 deletions src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,32 @@ pub struct BlockHeader {
serde_struct_impl!(BlockHeader, version, prev_blockhash, merkle_root, time, height, ext);

impl BlockHeader {
/// Returns true if this is a block with dynamic federations enabled.
pub fn is_dynafed(&self) -> bool {
if let ExtData::Dynafed {
..
} = self.ext
{
true
} else {
false
}
}

/// Remove the witness data of the block header.
/// This is all the data that can be removed without changing
/// the block hash.
pub fn clear_witness(&mut self) {
match &mut self.ext {
&mut ExtData::Proof { ref mut solution, .. } => {
*solution = Script::new();
},
&mut ExtData::Dynafed { ref mut signblock_witness, .. } => {
signblock_witness.clear();
},
}
}

/// Calculate the root of the dynafed params. Returns [None] when not dynafed.
pub fn calculate_dynafed_params_root(&self) -> Option<sha256::Midstate> {
match self.ext {
Expand Down