Skip to main content

Crate blueprint_gossip_primitives

Crate blueprint_gossip_primitives 

Source
Expand description

§Blueprint Gossip Primitives

Reusable abstractions for building gossip-based protocols in the Blueprint SDK.

This crate provides:

  • ProtocolNetwork trait for abstracting network operations
  • GossipManager for message deduplication and reliable delivery
  • MessageStore for efficient message storage with indexing
  • Mock implementations for testing without real network dependencies

§Design Principles

  1. Protocol Agnostic: These primitives work with any message type
  2. Testable: Mock implementations allow unit testing without mDNS/libp2p
  3. Event-Driven: Async streams instead of polling for efficient message handling
  4. 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;

Modules§

dedup
Message deduplication for gossip protocols
error
Error types for gossip primitives
network
Network abstraction for gossip protocols
store
Message storage with efficient indexing for gossip protocols