Expand description
Fast synchronization using database snapshots.
This module enables HOPR nodes to synchronize quickly with the network by downloading and installing pre-built database snapshots instead of processing all historical blockchain logs.
§Features
- HTTP/HTTPS Downloads: Secure download with retry logic and progress tracking
- Local File Support: Direct installation from local
file://
URLs - Archive Extraction: Safe tar.xz extraction with path traversal protection
- Database Validation: SQLite integrity checks and content verification
- Disk Space Management: Cross-platform space validation before operations
- Comprehensive Errors: Actionable error messages with recovery suggestions
§URL Support
https://example.com/snapshot.tar.xz
- Remote HTTP/HTTPS downloadsfile:///path/to/snapshot.tar.xz
- Local file system access
§Example
use std::path::Path;
use hopr_chain_indexer::snapshot::{SnapshotResult, SnapshotManager};
let manager = SnapshotManager::with_db(db)?;
let info = manager
.download_and_setup_snapshot(
"https://snapshots.hoprnet.org/logs.tar.xz",
Path::new("/data/hopr")
)
.await?;
println!("Installed snapshot: {} logs, latest block {}", info.log_count, info.latest_block.unwrap_or(0));
Re-exports§
pub use error::SnapshotError;
pub use error::SnapshotResult;
pub use validate::SnapshotInfo;
Modules§
- download
- Secure snapshot downloading with HTTP/HTTPS and local file support.
- error
- Error types for snapshot operations with user-friendly messages.
- extract
- Secure tar.xz archive extraction with path traversal protection.
- validate
- SQLite database validation for snapshot integrity verification.
Structs§
- Snapshot
Manager - Coordinates snapshot download, extraction, validation, and database integration.