Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #1088: Add BIP152 (Compact Blocks) structures
ee29910 BIP152: Test net msg ser/der and diff encoding (0xb10c) cd1aaaf BIP152: Add Compact Block unit test based on Elements (Steven Roose) d4d92a8 BIP152: Add Compact Blocks network messages (Steven Roose) f2fcdc8 BIP152: Add basic Compact Block structures (Steven Roose) a9a39c4 blockdata: Derive PartialOrd, Ord and Hash for BlockHeader (Steven Roose) Pull request description: > Adds the basic structures for BIP152 and a method to create a compact block from a full block. This is a rebase of #249 by stevenroose (see #249 (comment)) with a milestone for 29.0. I've added deserialization and serialization tests for the network messages and fixed an off-by-one bug in the deserialization of the differentially encoded varints in the `getblocktxn` message (see #249 (comment)). Closes #249. ACKs for top commit: tcharding: ACK ee29910 apoelstra: ACK ee29910 Tree-SHA512: 462a91576281f5a2ffdc2610769ea93970b60dac75a150c827966c48daec7cf93f526f9f202e7ba1dbb1410b49148579880260a3c3df298b98330c0d891a4cca
- Loading branch information
Showing
8 changed files
with
574 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//! | ||
//! BIP152 Compact Blocks network messages | ||
//! | ||
|
||
use crate::internal_macros::impl_consensus_encoding; | ||
use crate::util::bip152; | ||
|
||
/// sendcmpct message | ||
#[derive(PartialEq, Eq, Clone, Debug, Copy, PartialOrd, Ord, Hash)] | ||
pub struct SendCmpct { | ||
/// Request to be send compact blocks. | ||
pub send_compact: bool, | ||
/// Compact Blocks protocol version number. | ||
pub version: u64, | ||
} | ||
impl_consensus_encoding!(SendCmpct, send_compact, version); | ||
|
||
/// cmpctblock message | ||
/// | ||
/// Note that the rules for validation before relaying compact blocks is | ||
/// different from headers and regular block messages. Thus, you shouldn't use | ||
/// compact blocks when relying on an upstream full node to have validated data | ||
/// being forwarded to you. | ||
#[derive(PartialEq, Eq, Clone, Debug, PartialOrd, Ord, Hash)] | ||
pub struct CmpctBlock { | ||
/// The Compact Block. | ||
pub compact_block: bip152::HeaderAndShortIds, | ||
} | ||
impl_consensus_encoding!(CmpctBlock, compact_block); | ||
|
||
/// getblocktxn message | ||
#[derive(PartialEq, Eq, Clone, Debug, PartialOrd, Ord, Hash)] | ||
pub struct GetBlockTxn { | ||
/// The block transactions request. | ||
pub txs_request: bip152::BlockTransactionsRequest, | ||
} | ||
impl_consensus_encoding!(GetBlockTxn, txs_request); | ||
|
||
/// blocktxn message | ||
#[derive(PartialEq, Eq, Clone, Debug, PartialOrd, Ord, Hash)] | ||
pub struct BlockTxn { | ||
/// The requested block transactions. | ||
pub transactions: bip152::BlockTransactions, | ||
} | ||
impl_consensus_encoding!(BlockTxn, transactions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.