weave-sdk · network_manager
Source declarations, signatures and documentation for network_manager.
Source: sigil/weave/libs/weave-sdk/src/network_manager.rs. SHA-256: a7ad71ea6fb46df87b8754e1c3b60d69a3e4afeac35b5c1ebe4657895b643f45.
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.
network_manager::NetworkConfig
Configuration for the network layer.
#[derive(Debug, Clone)]
pub struct NetworkConfig {
/// Port for the DHT node.
pub dht_port: u16,
/// Port for the replication TCP listener (0 = random).
pub replication_port: u16,
/// DHT bootstrap peers (multiaddr format).
pub bootstrap_peers: Vec<String>,
/// Enable mDNS for local peer discovery.
pub enable_mdns: bool,
/// Interval between DHT lookup sweeps (seconds).
pub discovery_interval_secs: u64,
/// Maximum concurrent replication sessions.
pub max_replication_sessions: usize
}Source line: 342.
network_manager::ConnectedPeer
Information about a connected peer.
#[derive(Debug, Clone)]
pub struct ConnectedPeer {
/// Peer DID or identifier.
pub peer_id: String,
/// Socket address we are connected to.
pub address: SocketAddr,
/// Discovery keys being replicated with this peer.
pub discovery_keys: Vec<[u8; 32]>
}Source line: 411.
network_manager::NetworkManager
Manages DHT-based peer discovery and automatic replication.
The manager maintains:
- A DHT node for announce/lookup
- A TCP listener for incoming replication connections
- A set of tracked discovery keys (strands we want to replicate)
- Background tasks for periodic discovery sweeps
pub struct NetworkManager {
}Source line: 527.
network_manager::NetworkManager::new
Create a new network manager.
pub fn new(
identity: WeaveIdentity,
replication: Arc<ReplicationManager>,
config: NetworkConfig,
) -> Self;Source line: 570.
network_manager::NetworkManager::start
Start the network layer: DHT node, replication listener, discovery loop.
After this returns, the node is:
- Listening for incoming replication on a TCP port
- Running a DHT node for discovery
- Running a periodic discovery sweep
pub async fn start(&mut self) -> Result<()>;Source line: 598.
network_manager::NetworkManager::announce_strand
Announce a strand on the DHT so other peers can discover it.
This registers the strand's discovery key with the DHT and begins tracking it for automatic replication with discovered peers.
pub async fn announce_strand(
&self,
name: &str,
strand: Arc<tokio::sync::RwLock<Strand>>,
) -> Result<()>;Source line: 670.
network_manager::NetworkManager::lookup_strand
Look up peers who have a specific discovery key.
pub async fn lookup_strand(&self, discovery_key: &[u8; 32]) -> Result<Vec<PeerInfo>>;Source line: 763.
network_manager::NetworkManager::unannounce_strand
Stop announcing a strand and remove it from tracking.
pub async fn unannounce_strand(&self, discovery_key: &[u8; 32]) -> Result<()>;Source line: 799.
network_manager::NetworkManager::peer_count
Get the number of connected peers.
pub async fn peer_count(&self) -> usize;Source line: 809.
network_manager::NetworkManager::connected_peers
List all connected peers.
pub async fn connected_peers(&self) -> Vec<ConnectedPeer>;Source line: 814.
network_manager::NetworkManager::tracked_key_count
Get the number of tracked discovery keys.
pub async fn tracked_key_count(&self) -> usize;Source line: 824.
network_manager::NetworkManager::replication_addr
Get the replication listener address (if started).
pub fn replication_addr(&self) -> Option<SocketAddr>;Source line: 829.
network_manager::NetworkManager::dht_handle
Get the DHT handle (if started).
pub fn dht_handle(&self) -> Option<&DhtHandle>;Source line: 834.
network_manager::NetworkManager::weft_store
Production Weft store over the same live DHT handle (Ash data-path lock).
Call after [Self::start]. Uses /weft/v1/{manifest,chunk,availability}/…
keys only — never Strand discovery_key provider records. Do not start a
second Weft-only bootstrap when this is available.
pub fn weft_store(&self) -> Option<WeftDhtStore<DhtHandle>>;Source line: 843.
network_manager::NetworkManager::dht_bootstrap_addr
Multiaddr other local/LAN peers can use in LOOM_BOOTSTRAP.
pub fn dht_bootstrap_addr(&self) -> Option<String>;Source line: 848.
network_manager::NetworkManager::shutdown
Shut down the network layer.
pub async fn shutdown(&mut self) -> Result<()>;Source line: 856.
network_manager::NetworkManager::discover_now
Manually trigger a discovery sweep for all tracked keys.
This is useful for tests or when you want to force immediate peer discovery rather than waiting for the periodic interval.
pub async fn discover_now(&self) -> Result<usize>;Source line: 878.