iroh-gossip

Crates.ioiroh-gossip
lib.rsiroh-gossip
version
sourcesrc
created_at2023-08-28 20:31:03.562377
updated_at2025-02-04 18:27:37.673113
descriptiongossip messages over broadcast trees
homepage
repositoryhttps://github.com/n0-computer/iroh-gossip
max_upload_size
id957345
Cargo.toml error:TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
iroh-maintainers (github:n0-computer:iroh-maintainers)

documentation

README

iroh-gossip

This crate implements the iroh-gossip protocol. It is based on epidemic broadcast trees to disseminate messages among a swarm of peers interested in a topic. The implementation is based on the papers HyParView and PlumTree.

The crate is made up from two modules: The proto module is the protocol implementation, as a state machine without any IO. The net module connects the protocol to the networking stack from iroh-net.

The net module is optional behind the net feature flag (enabled by default).

Getting Started

The iroh-gossip protocol was designed to be used in conjunction with iroh. Iroh is a networking library for making direct connections, these connections are how gossip messages are sent.

Iroh provides a Router that takes an Endpoint and any protocols needed for the application. Similar to a router in webserver library, it runs a loop accepting incoming connections and routes them to the specific protocol handler, based on ALPN.

Here is a basic example of how to set up iroh-gossip with iroh:

use iroh::{protocol::Router, Endpoint};
use iroh_gossip::{net::Gossip, ALPN};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // create an iroh endpoint that includes the standard discovery mechanisms
    // we've built at number0
    let endpoint = Endpoint::builder().discovery_n0().bind().await?;

    // build gossip protocol
    let gossip = Gossip::builder().spawn(endpoint.clone()).await?;

    // setup router
    let router = Router::builder(endpoint.clone())
        .accept(ALPN, gossip.clone())
        .spawn()
        .await?;
    // do fun stuff with the gossip protocol
    router.shutdown().await?;
    Ok(())
}

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 226

cargo fmt