| 117 | |
| 118 | impl CircuitBlockHeader { |
| 119 | pub fn compute_block_hash(&self) -> [u8; 32] { |
| 120 | let mut hasher = Sha256::new(); |
| 121 | hasher.update(&self.version.to_le_bytes()); |
| 122 | hasher.update(&self.prev_block_hash); |
| 123 | hasher.update(&self.merkle_root); |
| 124 | hasher.update(&self.time.to_le_bytes()); |
| 125 | hasher.update(&self.bits.to_le_bytes()); |
| 126 | hasher.update(&self.nonce.to_le_bytes()); |
| 127 | let first_hash_result = hasher.finalize_reset(); |
| 128 | |
| 129 | hasher.update(first_hash_result); |
| 130 | let result: [u8; 32] = hasher |
| 131 | .finalize() |
| 132 | .try_into() |
| 133 | .expect("SHA256 should produce a 32-byte output"); |
| 134 | result |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | impl From<Header> for CircuitBlockHeader { |