#blockchain #data-stream

fuel-streams-core

Core components for working with streams of Fuel blockchain data

19 releases

new 0.0.28 Mar 14, 2025
0.0.25 Feb 13, 2025
0.0.16 Dec 28, 2024
0.0.13 Nov 28, 2024

#62 in #cryptocurrencies

Download history 172/week @ 2024-11-24 18/week @ 2024-12-01 28/week @ 2024-12-08 2/week @ 2024-12-15 335/week @ 2024-12-22 54/week @ 2024-12-29 2/week @ 2025-01-05 75/week @ 2025-01-19 212/week @ 2025-01-26 200/week @ 2025-02-02 131/week @ 2025-02-09 50/week @ 2025-02-16 11/week @ 2025-02-23 23/week @ 2025-03-02 183/week @ 2025-03-09

277 downloads per month
Used in 2 crates

Apache-2.0

690KB
16K SLoC


Logo

Fuel Streams Core

The core library for data streaming in the Fuel Data Systems project.

CI Coverage Crates.io MSRV crates.io docs

📚 Documentation   🐛 Report Bug   ✨ Request Feature

📝 About The Project

Fuel Streams Core is a library for building data streaming applications on the Fuel blockchain. It provides tools for efficient handling of real-time blockchain data, using NATS for scalable streaming and offering support for Fuel-specific data types.

[!NOTE] This crate is specifically modeled for the Fuel Data Systems project, and is not intended for general use outside of the project.

🛠️ Installing

Add this dependency to your Cargo.toml:

[dependencies]
fuel-streams-core = "*"

🚀 Usage

Here's a simple example to get you started with Fuel Streams Core:

use fuel_streams_core::prelude::*;
use fuel_streams_store::db::*;
use fuel_web_utils::api_key::*;
use fuel_message_broker::*;
use futures::StreamExt;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Connect to NATS server
    let db = Db::new(DbConnectionOpts::default()).await?;
    let broker = NatsMessageBroker::setup("nats://localhost:4222", None).await?;

    // Create or get existing stream for blocks
    let stream = Stream::<Block>::get_or_init(&broker, &db).await;

    // Subscribe to the stream
    let subject = BlocksSubject::new(); // blocks.*.*
    let api_key_role = ApiKeyRole::default();
    let mut subscription = stream.subscribe(
        subject,
        DeliverPolicy::New,
        &api_key_role
    )
    .await;

    // Process incoming blocks
    while let Some(block) = subscription.next().await {
        println!("Received block: {:?}", block?);
    }

    Ok(())
}

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

For more information on contributing, please see the CONTRIBUTING.md file in the root of the repository.

📜 License

This repo is licensed under the Apache-2.0 license. See LICENSE for more information.

Dependencies

~212MB
~4M SLoC