few more simplifications
This commit is contained in:
parent
3143ff75d0
commit
e167b3350a
|
@ -56,7 +56,7 @@ impl ChainVerifier {
|
||||||
|
|
||||||
fn ordered_verify(&self, block: &chain::Block, at_height: u32) -> Result<(), Error> {
|
fn ordered_verify(&self, block: &chain::Block, at_height: u32) -> Result<(), Error> {
|
||||||
// check that difficulty matches the adjusted level
|
// check that difficulty matches the adjusted level
|
||||||
if let Some(work) = self.work_required(block, at_height) {
|
if let Some(work) = self.work_required(at_height) {
|
||||||
if !self.skip_pow && work != block.header().nbits {
|
if !self.skip_pow && work != block.header().nbits {
|
||||||
trace!(target: "verification", "pow verification error at height: {}", at_height);
|
trace!(target: "verification", "pow verification error at height: {}", at_height);
|
||||||
trace!(target: "verification", "expected work: {}, got {}", work, block.header().nbits);
|
trace!(target: "verification", "expected work: {}, got {}", work, block.header().nbits);
|
||||||
|
@ -295,7 +295,7 @@ impl ChainVerifier {
|
||||||
Some(timestamps[timestamps.len() / 2])
|
Some(timestamps[timestamps.len() / 2])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn work_required(&self, block: &chain::Block, height: u32) -> Option<u32> {
|
fn work_required(&self, height: u32) -> Option<u32> {
|
||||||
if height == 0 {
|
if height == 0 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ impl Compact {
|
||||||
let mut word = self.0 & 0x007fffff;
|
let mut word = self.0 & 0x007fffff;
|
||||||
|
|
||||||
let result = if size <= 3 {
|
let result = if size <= 3 {
|
||||||
word >>= (8 * (3 - size as usize));
|
word >>= 8 * (3 - size as usize);
|
||||||
word.into()
|
word.into()
|
||||||
} else {
|
} else {
|
||||||
U256::from(word) << (8 * (size as usize - 3))
|
U256::from(word) << (8 * (size as usize - 3))
|
||||||
|
|
Loading…
Reference in New Issue