1use uhash_types::{Challenge, Difficulty};
4
5#[cfg(not(feature = "std"))]
6use alloc::vec::Vec;
7
8pub fn build_input(header: &[u8], nonce: u64) -> Vec<u8> {
10 let mut input = Vec::with_capacity(header.len() + 8);
11 input.extend_from_slice(header);
12 input.extend_from_slice(&nonce.to_le_bytes());
13 input
14}
15
16pub fn challenge_input(challenge: &Challenge, nonce: u64) -> Vec<u8> {
18 build_input(&challenge.header, nonce)
19}
20
21pub fn encode_difficulty(bits: u32) -> Difficulty {
23 Difficulty::new(bits)
24}