Skip to content

Commit effc26e

Browse files
committed
Merge #31: Add BlockHeader::clear_witness and ::is_dynafed methods
3e7c7b1 Add BlockHeader::clear_witness method (Steven Roose) 8b0d786 Add BlockHeader::is_dynafed (Steven Roose) Pull request description: Top commit has no ACKs. Tree-SHA512: df4b899bec11b24da2abcfeed2a81f607fb62e28159ad7c0aa1937101d847cd2dbf6531ba177eae274aed3301a523e24a947a90db1f8ece3d8e2fa23e8962cef
2 parents a5391b2 + 3e7c7b1 commit effc26e

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/block.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,32 @@ pub struct BlockHeader {
223223
serde_struct_impl!(BlockHeader, version, prev_blockhash, merkle_root, time, height, ext);
224224

225225
impl BlockHeader {
226+
/// Returns true if this is a block with dynamic federations enabled.
227+
pub fn is_dynafed(&self) -> bool {
228+
if let ExtData::Dynafed {
229+
..
230+
} = self.ext
231+
{
232+
true
233+
} else {
234+
false
235+
}
236+
}
237+
238+
/// Remove the witness data of the block header.
239+
/// This is all the data that can be removed without changing
240+
/// the block hash.
241+
pub fn clear_witness(&mut self) {
242+
match &mut self.ext {
243+
&mut ExtData::Proof { ref mut solution, .. } => {
244+
*solution = Script::new();
245+
},
246+
&mut ExtData::Dynafed { ref mut signblock_witness, .. } => {
247+
signblock_witness.clear();
248+
},
249+
}
250+
}
251+
226252
/// Calculate the root of the dynafed params. Returns [None] when not dynafed.
227253
pub fn calculate_dynafed_params_root(&self) -> Option<sha256::Midstate> {
228254
match self.ext {

0 commit comments

Comments
 (0)