cuprated/blockchain/
fast_sync.rs

1use std::slice;
2
3use cuprate_helper::network::Network;
4
5/// The hashes of the compiled in fast sync file.
6static FAST_SYNC_HASHES: &[[u8; 32]] = {
7    let bytes = include_bytes!("./fast_sync/fast_sync_hashes.bin");
8
9    if bytes.len() % 32 == 0 {
10        // SAFETY: The file byte length must be perfectly divisible by 32, checked above.
11        unsafe { slice::from_raw_parts(bytes.as_ptr().cast::<[u8; 32]>(), bytes.len() / 32) }
12    } else {
13        panic!();
14    }
15};
16
17/// Set the fast-sync hashes according to the provided values.
18pub fn set_fast_sync_hashes(fast_sync: bool, network: Network) {
19    cuprate_fast_sync::set_fast_sync_hashes(if fast_sync && network == Network::Mainnet {
20        FAST_SYNC_HASHES
21    } else {
22        &[]
23    });
24}