block::new() now sets a random pow on the header (#1128)

This commit is contained in:
Antioch Peverell 2018-06-02 15:17:07 +01:00 committed by GitHub
parent 0a80023527
commit 6fd2afccb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -396,7 +396,8 @@ impl Block {
/// transactions and the private key that will receive the reward. Checks /// transactions and the private key that will receive the reward. Checks
/// that all transactions are valid and calculates the Merkle tree. /// that all transactions are valid and calculates the Merkle tree.
/// ///
/// Only used in tests (to be confirmed, may be wrong here). /// TODO - Move this somewhere where only tests will use it.
/// *** Only used in tests. ***
/// ///
pub fn new( pub fn new(
prev: &BlockHeader, prev: &BlockHeader,
@ -404,7 +405,16 @@ impl Block {
difficulty: Difficulty, difficulty: Difficulty,
reward_output: (Output, TxKernel), reward_output: (Output, TxKernel),
) -> Result<Block, Error> { ) -> Result<Block, Error> {
Block::with_reward(prev, txs, reward_output.0, reward_output.1, difficulty) let mut block =
Block::with_reward(prev, txs, reward_output.0, reward_output.1, difficulty)?;
// Now set the pow on the header so block hashing works as expected.
{
let proof_size = global::proofsize();
block.header.pow = Proof::random(proof_size);
}
Ok(block)
} }
/// Hydrate a block from a compact block. /// Hydrate a block from a compact block.