reth_network/transactions/
policy.rs1use crate::transactions::config::{AnnouncementFilteringPolicy, TransactionPropagationPolicy};
2use reth_eth_wire::NetworkPrimitives;
3use std::fmt::Debug;
4
5#[derive(Debug)]
11pub struct NetworkPolicies<N: NetworkPrimitives> {
12 propagation: Box<dyn TransactionPropagationPolicy<N>>,
13 announcement: Box<dyn AnnouncementFilteringPolicy<N>>,
14}
15
16impl<N: NetworkPrimitives> NetworkPolicies<N> {
17 pub fn new(
19 propagation: impl TransactionPropagationPolicy<N>,
20 announcement: impl AnnouncementFilteringPolicy<N>,
21 ) -> Self {
22 Self { propagation: Box::new(propagation), announcement: Box::new(announcement) }
23 }
24
25 pub fn with_propagation(self, new_propagation: impl TransactionPropagationPolicy<N>) -> Self {
27 Self { propagation: Box::new(new_propagation), announcement: self.announcement }
28 }
29
30 pub fn with_announcement(self, new_announcement: impl AnnouncementFilteringPolicy<N>) -> Self {
32 Self { propagation: self.propagation, announcement: Box::new(new_announcement) }
33 }
34
35 pub fn propagation_policy(&self) -> &dyn TransactionPropagationPolicy<N> {
37 &*self.propagation
38 }
39
40 pub fn propagation_policy_mut(&mut self) -> &mut dyn TransactionPropagationPolicy<N> {
42 &mut *self.propagation
43 }
44
45 pub fn announcement_filter(&self) -> &dyn AnnouncementFilteringPolicy<N> {
47 &*self.announcement
48 }
49}