Weave documentation
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.rs
  • BasisStore — libs/weave-sdk/src/node.rs
  • ConnectedPeer — libs/weave-sdk/src/network_manager.rs
  • ForumStore — libs/weave-sdk/src/node.rs
  • GnosisStore — libs/weave-sdk/src/node.rs
  • LensStore — libs/weave-sdk/src/node.rs
  • LocusStore — libs/weave-sdk/src/node.rs
  • MessagingManager — libs/weave-sdk/src/messaging.rs
  • NetworkConfig — 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(())
}

On this page