Skip to content

Commit

Permalink
Merge branch 'develop' into zhangsoledad/remove_alias
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangsoledad authored Nov 20, 2018
2 parents 280df57 + a42b2fa commit 2b25aa5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 19 deletions.
8 changes: 0 additions & 8 deletions core/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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<UncleBlock>) -> 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
}
Expand Down
8 changes: 0 additions & 8 deletions core/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions verification/src/tests/uncle_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,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 {
Expand All @@ -115,6 +114,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
Expand Down

0 comments on commit 2b25aa5

Please sign in to comment.