blvm_protocol/bip152.rs
1//! BIP152 high-level compact block types (wire / serde).
2//!
3//! Reconstruction, short-id hashing, and transport negotiation stay in the node.
4//! Conversions to/from [`crate::network::CmpctBlockMessage`] live in `network.rs`.
5
6use crate::{BlockHeader, Transaction};
7use serde::{Deserialize, Serialize};
8
9/// Short transaction ID (6 bytes / 48 bits) per BIP152.
10pub type ShortTxId = [u8; 6];
11
12/// Compact block representation (header + short IDs + prefilled txs).
13#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
14pub struct CompactBlock {
15 /// Block header
16 pub header: BlockHeader,
17 /// Nonce for short ID calculation (64-bit)
18 pub nonce: u64,
19 /// Short transaction IDs (6 bytes each)
20 pub short_ids: Vec<ShortTxId>,
21 /// Prefilled transactions (full txs for selected indices)
22 pub prefilled_txs: Vec<(usize, Transaction)>,
23}