bitcoin/p2p/
message_compact_blocks.rs

1// SPDX-License-Identifier: CC0-1.0
2
3//!
4//! BIP152  Compact Blocks network messages
5//!
6
7use crate::bip152;
8use crate::internal_macros::impl_consensus_encoding;
9
10/// sendcmpct message
11#[derive(PartialEq, Eq, Clone, Debug, Copy, PartialOrd, Ord, Hash)]
12pub struct SendCmpct {
13    /// Request to be send compact blocks.
14    pub send_compact: bool,
15    /// Compact Blocks protocol version number.
16    pub version: u64,
17}
18impl_consensus_encoding!(SendCmpct, send_compact, version);
19
20/// cmpctblock message
21///
22/// Note that the rules for validation before relaying compact blocks is
23/// different from headers and regular block messages. Thus, you shouldn't use
24/// compact blocks when relying on an upstream full node to have validated data
25/// being forwarded to you.
26#[derive(PartialEq, Eq, Clone, Debug, PartialOrd, Ord, Hash)]
27pub struct CmpctBlock {
28    /// The Compact Block.
29    pub compact_block: bip152::HeaderAndShortIds,
30}
31impl_consensus_encoding!(CmpctBlock, compact_block);
32
33/// getblocktxn message
34#[derive(PartialEq, Eq, Clone, Debug, PartialOrd, Ord, Hash)]
35pub struct GetBlockTxn {
36    /// The block transactions request.
37    pub txs_request: bip152::BlockTransactionsRequest,
38}
39impl_consensus_encoding!(GetBlockTxn, txs_request);
40
41/// blocktxn message
42#[derive(PartialEq, Eq, Clone, Debug, PartialOrd, Ord, Hash)]
43pub struct BlockTxn {
44    /// The requested block transactions.
45    pub transactions: bip152::BlockTransactions,
46}
47impl_consensus_encoding!(BlockTxn, transactions);