Vecnopool API is a Rust-based backend for the Vecnopool Frontend, providing real-time data for a mining pool dashboard on the Vecnoscan network. Built with Actix Web, it serves REST API endpoints and WebSocket notifications for mined blocks, wallet balances, payments, miner statistics, shares, and hashrate data, backed by a PostgreSQL database.
REST API Endpoints:
/api/blocks: Lists recently mined blocks./api/balances: Retrieves wallet balances, filterable by address./api/payments: Fetches recent payments, filterable by address./api/shares: Provides miner share data./api/hashrate: Returns hashrate statistics, customizable by time range and address./api/miners: Delivers miner statistics.
- Rust: Version 1.56 or higher (uses
edition = "2021"). - Cargo: Rust's package manager.
- PostgreSQL: Version compatible with
sqlxandtokio-postgres. - Environment Variables:
SQL_URI: PostgreSQL connection string (e.g.,postgres://user:pass@localhost:5432/db).WINDOW_TIME_MS: Optional, defaults to 300,000ms for hashrate calculations.
- Clone the Repository:
git clone https://github.com/Vecno-Foundation/vecnopool-api
cd vecnopool-api-
Install Rust (if not already installed):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs |sh
-
Set Up Environment:
Create a .env file in the project root:
SQL_URI=postgres://user:password@localhost:5432/vecnopool WINDOW_TIME_MS=300000Ensure your PostgreSQL database is running and configured.
-
Install Dependencies:
cargo build
Running the API. Start the Server:
cargo runThe API runs on http://0.0.0.0:8080, serving:* REST endpoints: /api/blocks, /api/balances, /api/payments, /api/shares, /api/hashrate, /api/miners.
- WebSocket: /ws for real-time updates.