p2p: Add wrappers for messages that use `Vec`

In preparation to move `p2p` to its own crate, any `Vec<T>` that satisfies
`T: Encodable` will not trivially implement `Encodable` because of the
orphan rule. A type defined within p2p may implement `Encodable`,
however, and the simplest possible type is one that simply wraps the
vector. Three types that will implement `Encodable` within `p2p` are
added here.
This commit is contained in:
rustaceanrob 2025-05-27 13:55:21 +01:00
parent 5e0b86d2b1
commit 94bcff28b1
No known key found for this signature in database
GPG Key ID: F4DD8F8486EC0F1F
1 changed files with 12 additions and 0 deletions

View File

@ -163,6 +163,18 @@ pub struct V2NetworkMessage {
payload: NetworkMessage,
}
/// A list of inventory items.
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct InventoryPayload(pub Vec<message_blockdata::Inventory>);
/// A list of legacy p2p address messages.
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct AddrPayload(pub Vec<(u32, Address)>);
/// A list of v2 address messages.
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct AddrV2Payload(pub Vec<AddrV2Message>);
/// A Network message payload. Proper documentation is available on at
/// [Bitcoin Wiki: Protocol Specification](https://en.bitcoin.it/wiki/Protocol_specification)
#[derive(Clone, PartialEq, Eq, Debug)]