bitcoin/network/
message_filter.rs

1//!
2//! BIP157  Client Side Block Filtering network messages
3//!
4
5use hash_types::{BlockHash, FilterHash, FilterHeader};
6
7#[derive(PartialEq, Eq, Clone, Debug)]
8/// getcfilters message
9pub struct GetCFilters {
10    /// Filter type for which headers are requested
11    pub filter_type: u8,
12    /// The height of the first block in the requested range
13    pub start_height: u32,
14    /// The hash of the last block in the requested range
15    pub stop_hash: BlockHash,
16}
17impl_consensus_encoding!(GetCFilters, filter_type, start_height, stop_hash);
18
19#[derive(PartialEq, Eq, Clone, Debug)]
20/// cfilter message
21pub struct CFilter {
22    /// Byte identifying the type of filter being returned
23    pub filter_type: u8,
24    /// Block hash of the Bitcoin block for which the filter is being returned
25    pub block_hash: BlockHash,
26    /// The serialized compact filter for this block
27    pub filter: Vec<u8>,
28}
29impl_consensus_encoding!(CFilter, filter_type, block_hash, filter);
30
31#[derive(PartialEq, Eq, Clone, Debug)]
32/// getcfheaders message
33pub struct GetCFHeaders {
34    /// Byte identifying the type of filter being returned
35    pub filter_type: u8,
36    /// The height of the first block in the requested range
37    pub start_height: u32,
38    /// The hash of the last block in the requested range
39    pub stop_hash: BlockHash,
40}
41impl_consensus_encoding!(GetCFHeaders, filter_type, start_height, stop_hash);
42
43#[derive(PartialEq, Eq, Clone, Debug)]
44/// cfheaders message
45pub struct CFHeaders {
46    /// Filter type for which headers are requested
47    pub filter_type: u8,
48    /// The hash of the last block in the requested range
49    pub stop_hash: BlockHash,
50    /// The filter header preceding the first block in the requested range
51    pub previous_filter_header: FilterHeader,
52    /// The filter hashes for each block in the requested range
53    pub filter_hashes: Vec<FilterHash>,
54}
55impl_consensus_encoding!(CFHeaders, filter_type, stop_hash, previous_filter_header, filter_hashes);
56
57#[derive(PartialEq, Eq, Clone, Debug)]
58/// getcfcheckpt message
59pub struct GetCFCheckpt {
60    /// Filter type for which headers are requested
61    pub filter_type: u8,
62    /// The hash of the last block in the requested range
63    pub stop_hash: BlockHash,
64}
65impl_consensus_encoding!(GetCFCheckpt, filter_type, stop_hash);
66
67#[derive(PartialEq, Eq, Clone, Debug)]
68/// cfcheckpt message
69pub struct CFCheckpt {
70    /// Filter type for which headers are requested
71    pub filter_type: u8,
72    /// The hash of the last block in the requested range
73    pub stop_hash: BlockHash,
74    /// The filter headers at intervals of 1,000
75    pub filter_headers: Vec<FilterHeader>,
76}
77impl_consensus_encoding!(CFCheckpt, filter_type, stop_hash, filter_headers);