mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 11:31:08 +03:00
block::new() now sets a random pow on the header (#1128)
This commit is contained in:
parent
0a80023527
commit
6fd2afccb4
1 changed files with 12 additions and 2 deletions
|
@ -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.
|
||||||
|
|
Loading…
Reference in a new issue