Giter VIP home page Giter VIP logo

consentry's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.