pub struct SpamFilter { /* private fields */ }Expand description
Spam filter implementation
Implementations§
Source§impl SpamFilter
impl SpamFilter
Sourcepub fn with_config(config: SpamFilterConfig) -> Self
pub fn with_config(config: SpamFilterConfig) -> Self
Create a new spam filter with custom configuration
Sourcepub fn with_preset(preset: SpamFilterPreset) -> Self
pub fn with_preset(preset: SpamFilterPreset) -> Self
Create a new spam filter with a preset configuration
Presets provide easy-to-use configurations for common use cases:
Disabled: No spam filteringConservative: Lenient filtering, minimal false positivesModerate: Balanced filtering (default)Aggressive: Strong filtering, may have false positives
Sourcepub fn is_spam(&self, tx: &Transaction) -> SpamFilterResult
pub fn is_spam(&self, tx: &Transaction) -> SpamFilterResult
Check if a transaction is spam (without witness data)
This is the backward-compatible method. For better detection, use is_spam_with_witness.
Sourcepub fn is_spam_with_witness(
&self,
tx: &Transaction,
witnesses: Option<&[Witness]>,
utxo_set: Option<&UtxoSet>,
) -> SpamFilterResult
pub fn is_spam_with_witness( &self, tx: &Transaction, witnesses: Option<&[Witness]>, utxo_set: Option<&UtxoSet>, ) -> SpamFilterResult
Check if a transaction is spam (with optional witness data and UTXO set)
Witness data is required for detecting Taproot/SegWit-based Ordinals. UTXO set is optional but improves fee rate calculation accuracy. If witness data is not provided, detection will be less accurate.
Sourcepub fn filter_transaction(&self, tx: &Transaction) -> Option<Transaction>
pub fn filter_transaction(&self, tx: &Transaction) -> Option<Transaction>
Filter a transaction based on spam detection
Returns Some(tx) if transaction should be included (not spam),
or None if transaction should be filtered (spam).
Sourcepub fn filter_block(
&self,
transactions: &[Transaction],
) -> (Vec<Transaction>, SpamSummary)
pub fn filter_block( &self, transactions: &[Transaction], ) -> (Vec<Transaction>, SpamSummary)
Filter transactions from a block (without witness data)
Returns filtered transactions (non-spam only) and summary of filtered spam.
Important: This function filters entire transactions. For UTXO commitment processing,
use process_filtered_block in initial_sync.rs which correctly handles spam
transactions by removing spent inputs while filtering outputs.
This function is primarily used for:
- Bandwidth estimation (calculating filtered size)
- Statistics and reporting
- Network message filtering (where entire transactions can be dropped)
Do not use this for UTXO tree updates - it will cause UTXO set inconsistency when spam transactions spend non-spam inputs.
Sourcepub fn filter_block_with_witness(
&self,
transactions: &[Transaction],
witnesses: Option<&[Vec<Witness>]>,
) -> (Vec<Transaction>, SpamSummary)
pub fn filter_block_with_witness( &self, transactions: &[Transaction], witnesses: Option<&[Vec<Witness>]>, ) -> (Vec<Transaction>, SpamSummary)
Filter transactions from a block (with optional witness data)
Returns filtered transactions (non-spam only) and summary of filtered spam. Witness data improves detection accuracy for SegWit/Taproot-based spam.
Important: This function filters entire transactions. For UTXO commitment processing,
use process_filtered_block in initial_sync.rs which correctly handles spam
transactions by removing spent inputs while filtering outputs.
This function is primarily used for:
- Bandwidth estimation (calculating filtered size)
- Statistics and reporting
- Network message filtering (where entire transactions can be dropped)
Do not use this for UTXO tree updates - it will cause UTXO set inconsistency when spam transactions spend non-spam inputs.
Trait Implementations§
Source§impl Clone for SpamFilter
impl Clone for SpamFilter
Source§fn clone(&self) -> SpamFilter
fn clone(&self) -> SpamFilter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SpamFilter
impl RefUnwindSafe for SpamFilter
impl Send for SpamFilter
impl Sync for SpamFilter
impl Unpin for SpamFilter
impl UnsafeUnpin for SpamFilter
impl UnwindSafe for SpamFilter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more