Expand description
§Blueprint Gossip Primitives
Reusable abstractions for building gossip-based protocols in the Blueprint SDK.
This crate provides:
ProtocolNetworktrait for abstracting network operationsGossipManagerfor message deduplication and reliable deliveryMessageStorefor efficient message storage with indexing- Mock implementations for testing without real network dependencies
§Design Principles
- Protocol Agnostic: These primitives work with any message type
- Testable: Mock implementations allow unit testing without mDNS/libp2p
- Event-Driven: Async streams instead of polling for efficient message handling
- Memory Bounded: LRU caches prevent unbounded memory growth
§Example
ⓘ
use blueprint_gossip_primitives::{ProtocolNetwork, GossipManager, GossipConfig};
// Create a gossip manager with deduplication
let config = GossipConfig::default();
let mut gossip = GossipManager::new(config);
// Check if message should be processed (not a duplicate)
if gossip.should_process(&message_hash) {
// Process and re-gossip
gossip.mark_seen(message_hash);
}Re-exports§
pub use dedup::DeduplicationCache;pub use dedup::GossipConfig;pub use dedup::GossipManager;pub use error::GossipError;pub use network::MessageStream;pub use network::NetworkEvent;pub use network::ProtocolNetwork;pub use store::MessageEntry;pub use store::MessageStore;