p2p: Remove legacy encoding from `message_bloom`
What changed, and why it matters
This commit removes old, unused encoding code for Bitcoin peer-to-peer bloom filter messages. It is a cleanup change that deletes legacy implementations after newer replacement code was already in place. There is no indication this fixes a security bug or introduces a vulnerability.
No security action required. Treat as routine refactoring/cleanup. Reviewers may optionally verify that the newer encoding implementations produce byte-identical output for the removed legacy implementations, but the diff itself shows no security issue.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit deletes legacy Encodable/Decodable consensus encoding implementations and the impl_consensus_encoding! macro invocations for FilterLoad, BloomFlags, and FilterAdd in p2p/src/message_bloom.rs. These types already have newer encoding::Encode/encoding::Decode implementations using the project’s newer encoding framework, so the removed code appears to be dead/legacy code. No functional behavior changes are visible in the diff.
Changed components
p2p/src/message_bloom.rsInspect captured patch +0 / −30
diff --git a/p2p/src/message_bloom.rs b/p2p/src/message_bloom.rs
index ee995913..69ef393b 100644
--- a/p2p/src/message_bloom.rs
+++ b/p2p/src/message_bloom.rs
@@ -8,14 +8,10 @@ use alloc::vec::Vec;
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
-use bitcoin::consensus::{encode, Decodable, Encodable, ReadExt};
use encoding::{
ArrayDecoder, ArrayEncoder, ByteVecDecoder, BytesEncoder, CompactSizeEncoder, Decoder4,
Encoder2, Encoder3,
};
-use io::{BufRead, Write};
-
-use crate::consensus::impl_consensus_encoding;
#[rustfmt::skip] // Keep public re-exports separate.
#[doc(no_inline)]
@@ -111,8 +107,6 @@ impl encoding::Decode for FilterLoad {
}
}
-impl_consensus_encoding!(FilterLoad, filter, hash_funcs, tweak, flags);
-
/// Bloom filter update flags
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum BloomFlags {
@@ -187,28 +181,6 @@ impl encoding::Decode for BloomFlags {
fn decoder() -> Self::Decoder { BloomFlagsDecoder(ArrayDecoder::new()) }
}
-impl Encodable for BloomFlags {
- fn consensus_encode<W: Write + ?Sized>(&self, w: &mut W) -> Result<usize, io::Error> {
- w.write_all(&[match self {
- Self::None => 0,
- Self::All => 1,
- Self::PubkeyOnly => 2,
- }])?;
- Ok(1)
- }
-}
-
-impl Decodable for BloomFlags {
- fn consensus_decode<R: BufRead + ?Sized>(r: &mut R) -> Result<Self, encode::Error> {
- Ok(match r.read_u8()? {
- 0 => Self::None,
- 1 => Self::All,
- 2 => Self::PubkeyOnly,
- _ => return Err(crate::consensus::parse_failed_error("unknown bloom flag")),
- })
- }
-}
-
/// `filteradd` message updates the current filter with new data
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct FilterAdd {
@@ -264,8 +236,6 @@ impl encoding::Decode for FilterAdd {
fn decoder() -> Self::Decoder { FilterAddDecoder(FilterAddInnerDecoder::new()) }
}
-impl_consensus_encoding!(FilterAdd, data);
-
/// Error types for bloom filter messages.
pub mod error {
use core::convert::Infallible;
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.