Skip to main content

IPDiversityConfig

Struct IPDiversityConfig 

Source
pub struct IPDiversityConfig {
Show 15 fields pub max_nodes_per_ipv6_64: usize, pub max_nodes_per_ipv6_48: usize, pub max_nodes_per_ipv6_32: usize, pub max_nodes_per_ipv4_32: Option<usize>, pub max_nodes_per_ipv4_24: Option<usize>, pub max_nodes_per_ipv4_16: Option<usize>, pub ipv4_limit_floor: Option<usize>, pub ipv4_limit_ceiling: Option<usize>, pub ipv6_limit_floor: Option<usize>, pub ipv6_limit_ceiling: Option<usize>, pub max_per_ip_cap: usize, pub max_network_fraction: f64, pub max_nodes_per_asn: usize, pub enable_geolocation_check: bool, pub min_geographic_diversity: usize,
}
Expand description

Configuration for IP diversity enforcement at multiple subnet levels

Fields§

§max_nodes_per_ipv6_64: usize

Maximum nodes per /64 subnet (default: 1)

§max_nodes_per_ipv6_48: usize

Maximum nodes per /48 allocation (default: 3)

§max_nodes_per_ipv6_32: usize

Maximum nodes per /32 region (default: 10)

§max_nodes_per_ipv4_32: Option<usize>

Optional guaranteed minimum for nodes per single IPv4 address (/32). When None (default), the dynamic per-IP limit is used alone. When Some(n), the effective limit is max(n, dynamic_per_ip), ensuring at least n nodes are allowed even when the dynamic formula yields a lower value (e.g. during bootstrap).

§max_nodes_per_ipv4_24: Option<usize>

Optional guaranteed minimum for nodes per /24 subnet (Class C). When None (default), dynamic_per_ip * 3 is used alone. When Some(n), the effective limit is max(n, dynamic_per_ip * 3).

§max_nodes_per_ipv4_16: Option<usize>

Optional guaranteed minimum for nodes per /16 subnet (Class B). When None (default), dynamic_per_ip * 10 is used alone. When Some(n), the effective limit is max(n, dynamic_per_ip * 10).

§ipv4_limit_floor: Option<usize>

Optional floor for all IPv4 subnet limits. When set, the effective limit at every IPv4 prefix level (/32, /24, /16) will be at least this value, overriding the dynamic calculation and existing hard caps.

§ipv4_limit_ceiling: Option<usize>

Optional ceiling for all IPv4 subnet limits. When set, the effective limit at every IPv4 prefix level will be at most this value.

§ipv6_limit_floor: Option<usize>

Optional floor for all IPv6 subnet limits.

§ipv6_limit_ceiling: Option<usize>

Optional ceiling for all IPv6 subnet limits.

§max_per_ip_cap: usize

Absolute maximum nodes allowed per single IP (default: 50)

§max_network_fraction: f64

Maximum fraction of network any single IP can represent (default: 0.005 = 0.5%)

§max_nodes_per_asn: usize

Maximum nodes per AS number (default: 20)

§enable_geolocation_check: bool

Enable GeoIP-based diversity checks

§min_geographic_diversity: usize

Minimum number of different countries required

Implementations§

Source§

impl IPDiversityConfig

Source

pub fn testnet() -> Self

Create a testnet configuration with relaxed diversity requirements.

This is useful for testing environments like Digital Ocean where all nodes share the same ASN (AS14061). The relaxed limits allow many nodes from the same provider while still maintaining some diversity tracking.

§Warning

This configuration should NEVER be used in production as it significantly weakens Sybil attack protection.

Source

pub fn permissive() -> Self

Create a permissive configuration that effectively disables diversity checks.

This is useful for local development and unit testing where all nodes run on localhost or the same machine.

Source

pub fn is_relaxed(&self) -> bool

Check if this is a testnet or permissive configuration.

Trait Implementations§

Source§

impl Clone for IPDiversityConfig

Source§

fn clone(&self) -> IPDiversityConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IPDiversityConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for IPDiversityConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for IPDiversityConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for IPDiversityConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,