A high-performance Bitcoin blockchain data scanner and API server built with Rust.
BitcoinScan is a Rust-based project that provides efficient scanning, storage, and querying of Bitcoin blockchain data. It uses RocksDB for fast data storage and retrieval, and provides a REST API for accessing Bitcoin address information.
- Fast Data Storage: Uses RocksDB with multi-threaded support and ZSTD compression
- REST API: Query Bitcoin address data through HTTP endpoints
- Scalable: Multi-threaded architecture for high-performance operations
- Tracing & Logging: Built-in request tracing and structured logging
- CORS Support: Configurable CORS for cross-origin requests
BitcoinScan/
├── src/ # Core library code
│ ├── db.rs # Database implementation
│ ├── error.rs # Error handling
│ ├── logger.rs # Logging setup
│ └── tree_store/ # Tree-based storage backend
├── crates/
│ ├── api/ # REST API server
│ └── importer/ # Data import tools
└── data/ # Database storage directory
- Rust 1.70 or later
- Cargo
# Clone the repository
git clone https://github.com/yourusername/BitcoinScan.git
cd BitcoinScan
# Build the project
cargo build --release
# Run tests
cargo testcargo run --bin apiThe server will start on http://localhost:8082 by default.
GET /health
Returns: OK
GET /api/1.0/address/count
Returns the total number of addresses in the database.
Response:
{
"count": 123456789
}GET /api/1.0/address/top?limit=10
Returns the first N addresses from the database.
Query Parameters:
limit(optional, default: 10): Number of addresses to return
Response:
{
"top_addresses": [...]
}GET /api/1.0/address/last?limit=10
Returns the last N addresses from the database.
GET /api/1.0/address/{address}
Returns information about a specific address.
The API server can be configured through the HttpConfig structure:
let config = HttpConfig {
address: "localhost:8082".to_owned(),
path: "/api".to_owned(),
version: "1.0".to_owned(),
cors: HttpCorsConfig::default(),
tls: HttpTlsConfig::default(),
};cargo run --bin apicargo testcargo clippycargo fmt- RocksDB: High-performance key-value store
- Read-only mode: Optimized for query operations
- Multi-threaded column families: Parallel data access
- Axum: Modern, ergonomic web framework
- Tower HTTP: Middleware for tracing and CORS
- Tokio: Async runtime with 16 worker threads
- Tracing: Structured logging and distributed tracing
- Request tracking: Automatic request/response logging
- Error reporting: Detailed error context
- Multi-threaded runtime with 16 worker threads
- Connection pooling for database access
- Efficient binary serialization
- ZSTD compression for data storage
Key dependencies:
axum- Web frameworkrocksdb- Database enginetokio- Async runtimetracing- Logging and diagnosticstower-http- HTTP middlewareserde- Serialization
Contributions are welcome! Please feel free to submit a Pull Request.
@dajneem23