From 61565957ad094d1599355d12c6d1ce61d5978b2c Mon Sep 17 00:00:00 2001 From: Liu-Cheng Xu Date: Thu, 6 Jun 2024 11:19:42 +0800 Subject: [PATCH] Add API for extracting the inner payload of RawNetworkMessage I'd like to take out the `payload` of RawNetworkMessage and then send it to the actual network message processor, but finds there is no way to do it. This commit adds such an API to expose the owned value of inner `payload`. --- bitcoin/src/p2p/message.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bitcoin/src/p2p/message.rs b/bitcoin/src/p2p/message.rs index 0b2cf3cdc..239ba91c8 100644 --- a/bitcoin/src/p2p/message.rs +++ b/bitcoin/src/p2p/message.rs @@ -310,6 +310,11 @@ impl RawNetworkMessage { Self { magic, payload, payload_len, checksum } } + /// Consumes the [RawNetworkMessage] instance and returns the inner payload. + pub fn into_payload(self) -> NetworkMessage { + self.payload + } + /// The actual message data pub fn payload(&self) -> &NetworkMessage { &self.payload }