MCPcopy Create free account
hub / github.com/BitVM/BitVM / check_hash_valid

Function check_hash_valid

header-chain/src/header_chain.rs:345–353  ·  view source on GitHub ↗
(hash: &[u8; 32], target_bytes: &[u8; 32])

Source from the content-addressed store, hash-verified

343}
344
345fn check_hash_valid(hash: &[u8; 32], target_bytes: &[u8; 32]) {
346 for i in 0..32 {
347 if hash[31 - i] < target_bytes[i] {
348 return;
349 } else if hash[31 - i] > target_bytes[i] {
350 panic!("Hash is not valid");
351 }
352 }
353}
354
355fn calculate_work(target: &[u8; 32]) -> U256 {
356 let target = U256::from_be_slice(target);

Callers 3

apply_blocksMethod · 0.85
test_hash_check_failFunction · 0.85
test_hash_check_passFunction · 0.85

Calls

no outgoing calls

Tested by 2

test_hash_check_failFunction · 0.68
test_hash_check_passFunction · 0.68