Weave Sdk
Networking
Networking primitives in the Weave SDK — DHT, swarm, and replication wired together behind a single SDK handle.
Purpose
Application SDK for identities, drives, stores, messaging, replication, and peer networking.
This page follows the real source shape for Weave Sdk and explains the workflow a developer is likely to use first.
Network contract
Document peer identity, topic selection, message framing, session lifetime, retry behavior, metrics, and what must be stable between releases. Any change here can strand peers, so examples should be exercised with at least two real processes.
Primary types to know
AgentMessage— libs/weave-sdk/src/messaging.rsBasisStore— libs/weave-sdk/src/node.rsConnectedPeer— libs/weave-sdk/src/network_manager.rsDriveAcl— libs/weave-sdk/src/visibility.rsDriveInfo— libs/weave-sdk/src/drive_manager.rsDriveManager— libs/weave-sdk/src/drive_manager.rsForumStore— libs/weave-sdk/src/node.rsGnosisStore— libs/weave-sdk/src/node.rsLensStore— libs/weave-sdk/src/node.rsLocusStore— libs/weave-sdk/src/node.rsMessagingManager— libs/weave-sdk/src/messaging.rsNetworkConfig— libs/weave-sdk/src/network_manager.rs
Example shape
use weave_sdk::prelude::*;
#[tokio::main]
async fn main() -> WeaveResult<()> {
let node = WeaveNode::builder()
.namespace("l1fe")
.identifier("networking-demo")
.storage_dir("/tmp/weave-networking")
.build()
.await?;
// start_network spins up the DHT and replication listeners, optionally
// enabling mDNS discovery for local peers.
node.start_network().await?;
// create_strand auto-announces the discovery_key to the DHT so peers can
// locate the writer and open replication streams.
node.create_strand("public-feed").await?;
node.append("public-feed", b"hello, network").await?;
node.announce_strand("public-feed").await?;
// discover_peers triggers a one-shot DHT lookup pass.
let discovered = node.discover_peers().await?;
println!(
"peers_now={} discovered_this_pass={} replication_addr={:?}",
node.peer_count().await,
discovered,
node.replication_addr().await,
);
node.stop_network().await?;
Ok(())
}