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: usizeMaximum 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: DurationDefault TTL for registrations.
Default: 1 hour
verify_attestations: boolWhether to verify attestations on registration.
Set to false only for isolated indexing evaluations. Default: true
replication_factor: NonZeroUsizeHow 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: NonZeroUsizeMaximum 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: boolWhether 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
impl SimulationConfig
Sourcepub const fn with_max_registrations_per_capability(self, max: usize) -> Self
pub const fn with_max_registrations_per_capability(self, max: usize) -> Self
Sets the maximum registrations at one capability path.
Sourcepub const fn with_default_ttl(self, ttl: Duration) -> Self
pub const fn with_default_ttl(self, ttl: Duration) -> Self
Sets the default TTL.
Sourcepub const fn with_verify_attestations(self, verify: bool) -> Self
pub const fn with_verify_attestations(self, verify: bool) -> Self
Enables or disables attestation verification.
Sourcepub const fn with_replication_factor(self, factor: NonZeroUsize) -> Self
pub const fn with_replication_factor(self, factor: NonZeroUsize) -> Self
Sets the number of copies the simulator claims to hold.
Sourcepub const fn with_page_size(self, page_size: NonZeroUsize) -> Self
pub const fn with_page_size(self, page_size: NonZeroUsize) -> Self
Sets the maximum number of registrations returned per lookup page.
Sourcepub const fn with_auto_expire(self, auto_expire: bool) -> Self
pub const fn with_auto_expire(self, auto_expire: bool) -> Self
Enables or disables automatic expiration.