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

Function target_to_bits

header-chain/src/header_chain.rs:310–320  ·  view source on GitHub ↗
(target: &[u8; 32])

Source from the content-addressed store, hash-verified

308}
309
310fn target_to_bits(target: &[u8; 32]) -> u32 {
311 let target_u256 = U256::from_be_slice(target);
312 let target_bits = target_u256.bits();
313 let size = (263 - target_bits) / 8;
314 let mut compact_target = [0u8; 4];
315 compact_target[0] = 33 - size as u8;
316 compact_target[1] = target[size - 1 as usize];
317 compact_target[2] = target[size + 0 as usize];
318 compact_target[3] = target[size + 1 as usize];
319 u32::from_be_bytes(compact_target)
320}
321
322fn calculate_new_difficulty(
323 epoch_start_time: u32,

Callers 4

apply_blocksMethod · 0.85
test_target_conversionFunction · 0.85
test_bits_to_targetFunction · 0.85

Calls

no outgoing calls

Tested by 3

test_target_conversionFunction · 0.68
test_bits_to_targetFunction · 0.68