Skip to main content

cuprated/blockchain/
fast_sync.rs

1use cuprate_helper::network::Network;
2
3/// The hashes of the compiled in fast sync file.
4///
5/// See `build.rs` for how this file is generated.
6static FAST_SYNC_HASHES: &[[u8; 32]] = &include!(concat!(env!("OUT_DIR"), "/fast_sync_hashes.rs"));
7
8/// Returns the fast-sync hashes for the given configuration.
9///
10/// Returns a non-empty slice only for mainnet with fast sync enabled.
11pub fn get_fast_sync_hashes(fast_sync: bool, network: Network) -> &'static [[u8; 32]] {
12    if fast_sync && network == Network::Mainnet {
13        FAST_SYNC_HASHES
14    } else {
15        &[]
16    }
17}
18
19#[cfg(test)]
20mod test {
21    use super::*;
22
23    /// Sanity check the fast sync hashes array.
24    #[test]
25    fn length() {
26        assert!(FAST_SYNC_HASHES.len() > 6642);
27    }
28}