Jamesmallon1 / solana-block-cacher

Solana Block Cacher is a high-performance, command-line interface (CLI) tool built in Rust. It is designed to efficiently pull blocks from the Solana blockchain, respecting the specified rate limits. This tool intelligently measures the user's connection speed and the rate limit to calculate the optimum number of threads for fetching blocks.
8 stars 1 forks source link
cache json solana solana-client

Solana Block Cacher

Crates.io Version Crates.io Total Downloads Coverage, Versioning, Deployment codecov License: MIT

Overview

Solana Block Cacher is a high-performance, command-line interface (CLI) tool built in Rust. It is designed to efficiently pull blocks from the Solana blockchain, respecting the specified rate limits. This tool intelligently measures the user's connection speed and the rate limit to calculate the optimum number of threads for fetching blocks. The blocks are processed in batches of 50 and written to a JSON file in an efficient manner.

Features

Installation

Before installing Solana Block Cacher, ensure you have Cargo installed on your system. If not, you can install it following the instructions on the official Cargo website.

To install Solana Block Cacher, use the following command:

cargo install solana-block-cacher

Usage

To use Solana Block Cacher, run the command with the desired arguments. Below are the available options:

solana-block-cacher [OPTIONS]

Getting an RPC URL

You can get a Solana RPC Url through QuickNode. I personally use the QuickNode Pro solution which allows me to retrieve millions of blocks a month for back testing.

Options

Example

solana-block-cacher --from_slot 12345 --to_slot 54321 --rpc_url https://crimson-chaotic-bird.solana-mainnet.quiknode.pro/*** --output_file my_blocks.json

Optimum Number of Threads Calculation

Given the following inputs:

The Optimum Number of Threads ($O_n$) can be calculated using the formula:

$$ O_n = \frac{R_l}{\min\left(\frac{W}{T}, R_l\right)} $$

Where:

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for improvements and suggestions.

Prior to contributing please ensure you read CONTRIBUTING.md.

License

This project is open source and available under MIT.

Happy Coding! 🚀🦀