1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! Grapevine: a modern, asynchronous peer-to-peer gossip protocol library.
//!
//! This library provides an implementation of gossip protocols for
//! distributed systems, supporting epidemic broadcast, anti-entropy, and
//! configurable transport layers.
//!
//! # Features
//!
//! - **Async/await**: Built on Tokio for efficient asynchronous I/O
//! - **Authenticated messages**: Every message is Ed25519-signed by its origin
//! and verified on receipt (see [`core::identity`] for the threat model)
//! - **Flexible transport**: TCP by default (QUIC planned for a future release)
//! - **Configurable**: Extensive configuration options
//!
//! # Example
//!
//! ```rust,no_run
//! use grapevine::{NodeConfig, Node};
//! use bytes::Bytes;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let config = NodeConfig::default();
//! let node = Node::new(config).await?;
//!
//! node.on_message(|origin, data| {
//! println!("Received from {origin}: {data:?}");
//! }).await;
//!
//! node.start().await?;
//! node.broadcast(Bytes::from("Hello, gossip!")).await?;
//! node.shutdown().await?;
//!
//! Ok(())
//! }
//! ```
pub use ;
pub use Error;
pub use ;
pub use ;
pub use ;
/// Result type alias for all operations.
pub type Result<T> = Result;