Skip to content

A standalone consensus networking service for listening to events

License

Notifications You must be signed in to change notification settings

chainbound/consentry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

consentry

🏗️🚧 WIP ️🏗🚧

Ethereum consensus network sentry

Overview

Consentry is a standalone consensus networking service, for listening to events like blocks, attestations and more over the libp2p consensus network.

The repo is adapted from the lighthouse_network crate.

Usage

This is more or less the main example:

use consentry::{GossipKind, Service, ServiceConfig};
use futures::StreamExt;

#[tokio::main]
async fn main() {
    // Build the service. ServiceConfig::default() will
    // come with sensible defaults (and bootnodes)
    let mut svc = Service::new(ServiceConfig::default());

    // Get a handle for interacting with the service
    let handle = svc.handle();

    // Subscribe to any `GossipKind` topics
    handle.subscribe_topic(GossipKind::BeaconBlock);

    // Open the event stream on which these topics will be sent
    let mut events = svc.pubsub_event_stream();

    // Spawn the service
    tokio::task::spawn(svc.start());

    while let Some(event) = events.next().await {
        println!("Event: {:?}", event.kind());
        println!("Peer count: {}", handle.peer_count().await);
    }
}

Running Example

Run the example with:

RUST_LOG=consentry=info cargo run --example main

This will print out received blocks and peer counts. You can also tune RUST_LOG to more granular tracing like debug or trace.