sui_indexer_alt_schema/blooms/
mod.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use move_core_types::account_address::AccountAddress;
5use sui_types::SUI_CLOCK_ADDRESS;
6
7pub mod blocked;
8pub mod bloom;
9pub mod hash;
10
11/// High-frequency identifiers excluded from bloom filters. These appear in most
12/// checkpoints, so including them would:
13/// - Cause queries to match nearly all blocks and checkpoints
14/// - Require fetching and probing more bloom filter rows at both levels
15const BLOOM_SKIP_ADDRESSES: &[AccountAddress] = &[AccountAddress::ZERO, SUI_CLOCK_ADDRESS];
16
17/// Returns true if the bytes should be excluded from bloom filter operations.
18pub fn should_skip_for_bloom(bytes: &[u8]) -> bool {
19    BLOOM_SKIP_ADDRESSES.iter().any(|id| id.as_ref() == bytes)
20}
21
22#[cfg(test)]
23mod tests {
24    use super::*;
25
26    #[test]
27    fn test_should_skip_for_bloom() {
28        assert!(should_skip_for_bloom(AccountAddress::ZERO.as_ref()));
29        assert!(should_skip_for_bloom(SUI_CLOCK_ADDRESS.as_ref()));
30
31        let mut bytes = [0u8; AccountAddress::LENGTH];
32        bytes[0] = 0x42;
33        assert!(!should_skip_for_bloom(&bytes));
34    }
35}