weave-weft · discovery
Source declarations, signatures and documentation for discovery.
Reviewed implementation boundary: Producer signatures must be computed over the exact manifest before validate/from_bytes or publication; an empty signature is rejected. Reader interfaces do not establish constant-memory storage, and chain reference metadata alone does not submit or prove anchoring. See /libraries/weft/publish.
Source: sigil/weave/models/weft/src/discovery.rs. SHA-256: db68b147ef56c44ca3afd063d3fc465fe436380bc60fd10b7c7f8f85629e0c45.
This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.
discovery::WEFT_AVAILABILITY_PROTOCOL
Protocol identifier for Weft availability records.
pub const WEFT_AVAILABILITY_PROTOCOL: &str;Source line: 11.
discovery::PeerId
Stable peer identifier used by Weft adapter boundaries.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct PeerId(String);Source line: 15.
discovery::PeerId::new
Create a peer id from non-empty text.
pub fn new(value: impl Into<String>) -> Result<Self>;Source line: 19.
discovery::PeerId::as_str
Borrow the peer id text.
pub fn as_str(&self) -> &str;Source line: 28.
discovery::AvailabilitySet
Which chunks a peer advertises for a Weft root.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum AvailabilitySet {
/// The peer advertises every chunk in the manifest.
All,
/// The peer advertises explicit chunk indexes.
Explicit(BTreeSet<u64>),
}Source line: 36.
discovery::AdvertisementScope
Why the peer is advertising the chunks.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum AdvertisementScope {
/// Original or authoritative provider.
Provider,
/// Durable mirror.
Mirror,
/// Opportunistic cache.
Cache,
}Source line: 46.
discovery::AvailabilityAdvertisement
Bounded chunk availability advertisement.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct AvailabilityAdvertisement {
/// Protocol identifier.
pub protocol: String,
/// Weft Merkle root.
pub root: WeftHash,
/// Manifest chunk size.
pub chunk_size: u64,
/// Manifest chunk count.
pub chunk_count: u64,
/// Original payload length.
pub total_len: u64,
/// Advertising peer.
pub peer: PeerId,
/// Advertised chunk indexes.
pub chunks: AvailabilitySet,
/// Advertisement scope.
pub scope: AdvertisementScope,
/// Time-to-live in seconds.
pub ttl_secs: u64
}Source line: 57.
discovery::AvailabilityAdvertisement::new
Construct and validate an advertisement.
#[allow(clippy::too_many_arguments)]
pub fn new(
root: WeftHash,
chunk_size: u64,
chunk_count: u64,
total_len: u64,
peer: PeerId,
chunks: AvailabilitySet,
scope: AdvertisementScope,
ttl_secs: u64,
) -> Result<Self>;Source line: 81.
discovery::AvailabilityAdvertisement::covers
Return true if this advertisement covers the given chunk index.
pub fn covers(&self, chunk_index: u64) -> bool;Source line: 128.
discovery::DiscoveryPublisher
Discovery boundary implemented by DHT/libp2p adapters.
#[async_trait]
pub trait DiscoveryPublisher: Send + Sync {
/// Advertise local availability.
async fn advertise(&self, advertisement: AvailabilityAdvertisement) -> Result<()>;
/// Discover advertisements for a Weft root.
async fn discover(&self, root: WeftHash) -> Result<Vec<AvailabilityAdvertisement>>;
}Source line: 138.
discovery::InMemoryDiscovery
Deterministic in-memory discovery implementation for tests and local use.
#[derive(Default)]
pub struct InMemoryDiscovery {
}Source line: 148.
discovery::FailClosedDiscovery
Deprecated placeholder that always returns [crate::WeftError::Unsupported].
Not a production adapter. Product discovery must construct
[crate::dht::WeftDhtStore] over a live weave_dht::DhtHandle
(see [crate::live::store_from_handle] / [crate::live::connect_primary_trio]
when the dht feature is enabled). Kept only so accidental links fail loudly.
#[deprecated(
since = "0.1.0",
note = "production must use WeftDhtStore over a live DhtHandle (feature = \"dht\"); FailClosedDiscovery is not a discovery adapter"
)]
#[derive(Debug, Default, Clone, Copy)]
pub struct FailClosedDiscovery;Source line: 186.