roll the system fork version into the consensus hash

This commit is contained in:
Jude Nelson
2019-02-07 15:29:57 -05:00
parent 0cb854d272
commit 9ca2ac9817

View File

@@ -32,6 +32,7 @@ use burnchains::BurnchainHeaderHash;
use burnchains::BurnchainBlock;
use sha2::Sha256;
use util::hash::Hash160;
use crypto::ripemd160::Ripemd160;
@@ -41,6 +42,8 @@ use rusqlite::Transaction;
use self::db::burndb::BurnDB;
use self::db::Error as db_error;
use core::SYSTEM_FORK_SET_VERSION;
use util::log;
pub struct ConsensusHash([u8; 20]);
@@ -53,6 +56,12 @@ impl_array_newtype!(BlockHeaderHash, u8, 32);
impl_array_hexstring_fmt!(BlockHeaderHash);
impl_byte_array_newtype!(BlockHeaderHash, u8, 32);
impl BlockHeaderHash {
pub fn to_hash160(&self) -> Hash160 {
Hash160::from_sha256(&self.0)
}
}
pub struct VRFSeed([u8; 32]);
impl_array_newtype!(VRFSeed, u8, 32);
impl_array_hexstring_fmt!(VRFSeed);
@@ -104,6 +113,9 @@ impl ConsensusHash {
use sha2::Digest;
let mut hasher = Sha256::new();
// fork-set version...
hasher.input(SYSTEM_FORK_SET_VERSION);
// ops hash...
hasher.input(opshash.as_bytes());
@@ -181,7 +193,6 @@ pub struct BlockSnapshot {
pub canonical: bool
}
impl BlockSnapshot {
/// Make a block snapshot from is block's data and the previous block
pub fn next_snapshot<A, K>(tx: &mut Transaction, first_block_height: u64, block: &BurnchainBlock<A, K>) -> Result<BlockSnapshot, db_error>