From 8b0d786b8d04b57c6a1dcdd6f20b5e15a0ff05d5 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Wed, 25 Sep 2019 00:08:24 +0200 Subject: [PATCH 1/2] Add BlockHeader::is_dynafed --- src/block.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/block.rs b/src/block.rs index 4a88d576..f51c4dc8 100644 --- a/src/block.rs +++ b/src/block.rs @@ -223,6 +223,18 @@ 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 + } + } + /// Calculate the root of the dynafed params. Returns [None] when not dynafed. pub fn calculate_dynafed_params_root(&self) -> Option { match self.ext { From 3e7c7b1cc0881fee1247e189baa0275dcb8ec1fe Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Fri, 20 Sep 2019 18:10:46 +0100 Subject: [PATCH 2/2] Add BlockHeader::clear_witness method --- src/block.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/block.rs b/src/block.rs index f51c4dc8..e19a943b 100644 --- a/src/block.rs +++ b/src/block.rs @@ -235,6 +235,20 @@ impl BlockHeader { } } + /// 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 { match self.ext {