Skip to main content

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