diff --git a/core/src/block.rs b/core/src/block.rs index 3064144854..4a1f4309e1 100644 --- a/core/src/block.rs +++ b/core/src/block.rs @@ -32,10 +32,6 @@ impl Block { &self.header } - pub fn mut_header(&mut self) -> &mut Header { - &mut self.header - } - pub fn is_genesis(&self) -> bool { self.header.is_genesis() } @@ -102,15 +98,11 @@ impl BlockBuilder { } pub fn uncle(mut self, uncle: UncleBlock) -> Self { - *self.inner.mut_header().mut_raw().mut_uncles_count() = - self.inner.header().raw().uncles_count() + 1; self.inner.uncles.push(uncle); self } pub fn uncles(mut self, uncles: Vec) -> Self { - *self.inner.mut_header().mut_raw().mut_uncles_count() = - self.inner.header().raw().uncles_count() + uncles.len() as u32; self.inner.uncles.extend(uncles); self } diff --git a/core/src/header.rs b/core/src/header.rs index d1e8775ad8..36300336d3 100644 --- a/core/src/header.rs +++ b/core/src/header.rs @@ -138,18 +138,10 @@ impl Header { self.raw.uncles_hash } - pub fn raw(&self) -> &RawHeader { - &self.raw - } - pub fn into_raw(self) -> RawHeader { self.raw } - pub fn mut_raw(&mut self) -> &mut RawHeader { - &mut self.raw - } - pub fn uncles_count(&self) -> u32 { self.raw.uncles_count } diff --git a/verification/src/tests/uncle_verifier.rs b/verification/src/tests/uncle_verifier.rs index 6349502bce..c0674f984c 100644 --- a/verification/src/tests/uncle_verifier.rs +++ b/verification/src/tests/uncle_verifier.rs @@ -94,13 +94,12 @@ fn test_uncle_verifier() { let verifier = UnclesVerifier::new(shared.clone()); - let mut block = BlockBuilder::default() + let block = BlockBuilder::default() .block(chain1.last().cloned().unwrap()) .uncle(chain2.last().cloned().unwrap().into()) .build(); - *block.mut_header().mut_raw().mut_uncles_count() = 0; - // Uncles not match uncles_hash + // Uncles not match uncles_count assert_eq!( verifier.verify(&block), Err(Error::Uncles(UnclesError::MissMatchCount { @@ -113,6 +112,7 @@ fn test_uncle_verifier() { let block = BlockBuilder::default() .block(chain1.last().cloned().unwrap()) + .header(HeaderBuilder::default().uncles_count(1).build()) .uncle(chain2.last().cloned().unwrap().into()) .build(); // Uncles not match uncles_hash