Expand description
Compact Block Relay (BIP152)
Implements the compact block protocol that allows peers to relay blocks using short transaction IDs rather than full transactions. Since most transactions in a new block are already in the receiver’s mempool, only a compact summary needs to be sent.
§Protocol Flow
-
Sender constructs a
CompactBlockfrom a full block:- Header + nonce
- Short transaction IDs (first 6 bytes of SipHash)
- A few “prefilled” transactions (always the coinbase, plus any the sender guesses the receiver doesn’t have)
-
Receiver matches short IDs against its mempool:
- If all transactions are found → reconstruct the full block
- If some are missing → send
GetBlockTxnto request them - Sender replies with
BlockTxncontaining the missing transactions
§References
Structs§
- Block
Transactions - Response with the missing transactions.
- Compact
Block - A compact block (BIP152
cmpctblock). - GetBlock
Transactions - A request for missing transactions from a compact block.
- Prefilled
Transaction - A prefilled transaction: index in the block + the full transaction.
Enums§
- Reconstruct
Result - Result of attempting to reconstruct a block from a compact block.
Functions§
- compute_
short_ txid - Compute a 6-byte short transaction ID for a given txid.
Type Aliases§
- Short
TxId - A 6-byte short transaction ID used in compact blocks.