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.
Read the node declarations for exact signatures.
Network contract
start_network starts the configured network listener and reinstalls sparse-session clients for loaded remote strands. create_strand creates local storage; publication requires explicit announce_strand. discover_peers returns the immediate discovery sweep count, not proof of successful data replication. Verify a remote read separately. The messaging transport has separate confidentiality and verification limitations.
Primary types to know
AgentMessage— libs/weave-sdk/src/messaging.rsBasisStore— libs/weave-sdk/src/node.rsConnectedPeer— libs/weave-sdk/src/network_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 local storage, append, then explicitly announce its writer.
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(())
}