Skip to main content

SimulationConfig

Struct SimulationConfig 

Source
pub struct SimulationConfig {
    pub max_registrations_per_capability: usize,
    pub default_ttl: Duration,
    pub verify_attestations: bool,
    pub replication_factor: NonZeroUsize,
    pub page_size: NonZeroUsize,
    pub auto_expire: bool,
}
Expand description

Configuration for the simulated DHT.

Controls behavior such as replication factor, TTL, paging, and verification.

Fields§

§max_registrations_per_capability: usize

Maximum registrations at one capability path.

This bounds the key an agent registers at, and only that key. A record is materialized at every ancestor key as well, but it appears there because of the path it chose rather than by choosing that key, so an ancestor’s occupancy is not charged to it. Bounding ancestors instead would let whoever fills a popular top-level prefix decide whether an unrelated agent may register anywhere beneath it (issue #54).

An ancestor key therefore holds whatever its subtree holds, which is the direct model’s premise: it applies where one store owns the namespace and a stored value has no practical size bound. A store that does bound a value is required to shard instead, per SPECIFICATION.md §6.2.

The default of 1000 is therefore a simulator affordance, not a figure a deployment can be sized against. A Kademlia overlay bounds a record at the wire size a peer will accept, which for libp2p-kad is 1 to 27 registrations, which is exactly why agent-uri-dht-libp2p shards rather than storing a subtree at one key. Code that handles DhtError::KeyCapacityExceeded ports to it. A capacity chosen against this number does not.

Default: 1000

§default_ttl: Duration

Default TTL for registrations.

Default: 1 hour

§verify_attestations: bool

Whether to verify attestations on registration.

Set to false only for isolated indexing evaluations. Default: true

§replication_factor: NonZeroUsize

How many copies the simulator claims to hold.

The simulator holds exactly one authoritative copy, so this is 1 and every crate::Quorum resolves to 1 against it. It exists so that quorum arithmetic is exercised rather than bypassed. Default: 1

§page_size: NonZeroUsize

Maximum registrations returned in one lookup page.

The simulator could return every match at once, but a distributed backend cannot, so it pages deliberately. Callers written against an unpaged simulator break on a real backend. Default: 64

§auto_expire: bool

Whether expiry happens without being asked.

When set, lookups omit lapsed records and writes evict them, so a store in use stays clean without anyone calling SimulatedDht::expire_stale. When clear, lapsed records stay visible and stay stored until that call, which is what an evaluation measuring how much of a namespace has gone stale needs.

Default: true

Implementations§

Source§

impl SimulationConfig

Source

pub fn new() -> Self

Creates a new configuration with defaults.

Source

pub const fn with_max_registrations_per_capability(self, max: usize) -> Self

Sets the maximum registrations at one capability path.

Source

pub const fn with_default_ttl(self, ttl: Duration) -> Self

Sets the default TTL.

Source

pub const fn with_verify_attestations(self, verify: bool) -> Self

Enables or disables attestation verification.

Source

pub const fn with_replication_factor(self, factor: NonZeroUsize) -> Self

Sets the number of copies the simulator claims to hold.

Source

pub const fn with_page_size(self, page_size: NonZeroUsize) -> Self

Sets the maximum number of registrations returned per lookup page.

Source

pub const fn with_auto_expire(self, auto_expire: bool) -> Self

Enables or disables automatic expiration.

Trait Implementations§

Source§

impl Clone for SimulationConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SimulationConfig

Source§

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

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

impl Default for SimulationConfig

Source§

fn default() -> Self

Returns the “default value” for a type. 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, 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 = !

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

fn try_from(value: U) -> Result<T, !>

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