Weave documentation
Rust referenceweave-dht

weave-dht · weave

Source declarations, signatures and documentation for weave.

Source: sigil/weave/network/weave-dht/src/weave.rs. SHA-256: 7cc581ece48521fcfd2995cd154f05c27388ffe8b8f7e9db2cd13c35388fe246.

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.

weave::WeaveDhtAdapter

Weave DHT Adapter operations

#[async_trait]
pub trait WeaveDhtAdapter {
    /// Find peers for a topic
    async fn lookup(&self, topic: &[u8; 32]) -> Result<Vec<PeerInfo>>;

    /// Announce this peer for a topic
    async fn announce(&self, topic: &[u8; 32], opts: AnnounceOpts) -> Result<()>;

    /// Stop announcing for a topic
    async fn unannounce(&self, topic: &[u8; 32]) -> Result<()>;

    /// Store immutable value (content-addressed)
    async fn immutable_put(&self, value: &[u8]) -> Result<[u8; 32]>;

    /// Get immutable value by hash
    async fn immutable_get(&self, hash: &[u8; 32]) -> Result<Vec<u8>>;

    /// Store mutable value with sequence number
    async fn mutable_put(&self, keypair: &OasKeyPair, value: &[u8], seq: u64) -> Result<()>;

    /// Get latest mutable value
    async fn mutable_get(&self, pubkey: &[u8; 32]) -> Result<MutableValue>;
}

Source line: 17.

weave::PeerInfo

Peer information

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct PeerInfo {
/// Optional Ed25519 public key of the peer, if learned via Identify or out-of-band

pub public_key: Option<[u8; 32]>,
/// Known socket addresses for direct connectivity

pub addresses: Vec<SocketAddr>,
/// Known relay multiaddrs as strings

pub relay_addresses: Vec<String>,
/// Optional libp2p PeerId (base58 string form)

pub peer_id: Option<String>
}

Source line: 42.

weave::AnnounceOpts

Options for announcing

#[derive(Debug, Clone, Default)]
pub struct AnnounceOpts {
pub port: Option<u16>,
pub public_key: Option<[u8; 32]>,
pub relay_address: Option<String>
}

Source line: 58.

weave::MutableValue

Mutable value with versioning

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MutableValue {
pub sequence: u64,
pub value: Vec<u8>,
pub signature: Vec<u8>,
// 64 bytes
pub public_key: Vec<u8>
}

Source line: 66.

weave::AnnouncementState

Announcement state

#[derive(Debug, Clone)]
pub struct AnnouncementState {
pub topic: [u8; 32],
pub port: u16,
pub public_key: Option<[u8; 32]>,
pub started: Instant,
pub refresh_interval: Duration
}

Source line: 75.

weave::WeaveDht

Weave DHT state and operations

pub struct WeaveDht {

}

Source line: 84.

weave::WeaveDhtConfig

Weave DHT configuration

#[derive(Debug, Clone)]
pub struct WeaveDhtConfig {
/// Enable Weave DHT protocol

pub enabled: bool,
/// Bootstrap nodes

pub bootstrap_nodes: Vec<String>,
/// Announcement refresh interval

pub announce_interval: Duration,
/// Maximum stored values

pub max_values: usize,
/// Cache timeout

pub cache_timeout: Duration,
/// Max envelope size in bytes (admission)

pub max_envelope_bytes: u64
}

Source line: 107.

weave::WeaveDht::new

#[cfg(feature = "rocksdb-store")]
pub fn new(config: WeaveDhtConfig) -> Self;

Source line: 142.

weave::WeaveDht::new

#[cfg(not(feature = "rocksdb-store"))]
pub fn new(config: WeaveDhtConfig) -> Self;

Source line: 154.

weave::WeaveDht::with_db

#[cfg(feature = "rocksdb-store")]
pub fn with_db(mut self, db: rocksdb::DB) -> Self;

Source line: 165.

weave::WeaveDht::admit_envelope

pub fn admit_envelope(&self, envelope: &DidEnvelope, last_seq: Option<u64>) -> Result<()>;

Source line: 172.

On this page