Merge pull request #276 from jonasnick/remove-spv
Remove confusing mentions of SPV
This commit is contained in:
commit
330e0fd587
|
@ -23,7 +23,7 @@
|
||||||
use bitcoin_hashes::{sha256d, Hash};
|
use bitcoin_hashes::{sha256d, Hash};
|
||||||
|
|
||||||
use util;
|
use util;
|
||||||
use util::Error::{SpvBadTarget, SpvBadProofOfWork};
|
use util::Error::{BlockBadTarget, BlockBadProofOfWork};
|
||||||
use util::hash::{BitcoinHash, MerkleRoot, bitcoin_merkle_root};
|
use util::hash::{BitcoinHash, MerkleRoot, bitcoin_merkle_root};
|
||||||
use util::uint::Uint256;
|
use util::uint::Uint256;
|
||||||
use consensus::encode::Encodable;
|
use consensus::encode::Encodable;
|
||||||
|
@ -169,13 +169,13 @@ impl BlockHeader {
|
||||||
|
|
||||||
let target = &self.target();
|
let target = &self.target();
|
||||||
if target != required_target {
|
if target != required_target {
|
||||||
return Err(SpvBadTarget);
|
return Err(BlockBadTarget);
|
||||||
}
|
}
|
||||||
let data: [u8; 32] = self.bitcoin_hash().into_inner();
|
let data: [u8; 32] = self.bitcoin_hash().into_inner();
|
||||||
let mut ret = [0u64; 4];
|
let mut ret = [0u64; 4];
|
||||||
LittleEndian::read_u64_into(&data, &mut ret);
|
LittleEndian::read_u64_into(&data, &mut ret);
|
||||||
let hash = &Uint256(ret);
|
let hash = &Uint256(ret);
|
||||||
if hash <= target { Ok(()) } else { Err(SpvBadProofOfWork) }
|
if hash <= target { Ok(()) } else { Err(BlockBadProofOfWork) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the total work of the block
|
/// Returns the total work of the block
|
||||||
|
|
|
@ -64,9 +64,9 @@ pub enum Error {
|
||||||
/// Network error
|
/// Network error
|
||||||
Network(network::Error),
|
Network(network::Error),
|
||||||
/// The header hash is not below the target
|
/// The header hash is not below the target
|
||||||
SpvBadProofOfWork,
|
BlockBadProofOfWork,
|
||||||
/// The `target` field of a block header did not match the expected difficulty
|
/// The `target` field of a block header did not match the expected difficulty
|
||||||
SpvBadTarget,
|
BlockBadTarget,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Error {
|
impl fmt::Display for Error {
|
||||||
|
@ -74,7 +74,7 @@ impl fmt::Display for Error {
|
||||||
match *self {
|
match *self {
|
||||||
Error::Encode(ref e) => fmt::Display::fmt(e, f),
|
Error::Encode(ref e) => fmt::Display::fmt(e, f),
|
||||||
Error::Network(ref e) => fmt::Display::fmt(e, f),
|
Error::Network(ref e) => fmt::Display::fmt(e, f),
|
||||||
Error::SpvBadProofOfWork | Error::SpvBadTarget => f.write_str(error::Error::description(self)),
|
Error::BlockBadProofOfWork | Error::BlockBadTarget => f.write_str(error::Error::description(self)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ impl error::Error for Error {
|
||||||
match *self {
|
match *self {
|
||||||
Error::Encode(ref e) => Some(e),
|
Error::Encode(ref e) => Some(e),
|
||||||
Error::Network(ref e) => Some(e),
|
Error::Network(ref e) => Some(e),
|
||||||
Error::SpvBadProofOfWork | Error::SpvBadTarget => None
|
Error::BlockBadProofOfWork | Error::BlockBadTarget => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,8 +92,8 @@ impl error::Error for Error {
|
||||||
match *self {
|
match *self {
|
||||||
Error::Encode(ref e) => e.description(),
|
Error::Encode(ref e) => e.description(),
|
||||||
Error::Network(ref e) => e.description(),
|
Error::Network(ref e) => e.description(),
|
||||||
Error::SpvBadProofOfWork => "target correct but not attained",
|
Error::BlockBadProofOfWork => "block target correct but not attained",
|
||||||
Error::SpvBadTarget => "target incorrect",
|
Error::BlockBadTarget => "block target incorrect",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue