rustywallet_batch/
lib.rs

1//! # rustywallet-batch
2//!
3//! High-performance batch key generation for cryptocurrency wallets.
4//!
5//! This crate provides efficient APIs for generating large batches of private keys
6//! with parallel processing, SIMD optimization, and memory-efficient streaming.
7//!
8//! ## Features
9//!
10//! - **Batch Generation**: Generate millions of keys efficiently
11//! - **Parallel Processing**: Utilize all CPU cores with rayon
12//! - **Memory Streaming**: Process unlimited keys without memory exhaustion
13//! - **Incremental Scanning**: Scan key ranges using EC point addition
14//! - **SIMD Optimization**: Use SIMD instructions for faster processing
15//! - **Memory-Mapped Output**: Write directly to files without buffering
16//! - **Resume Capability**: Checkpoint and resume long-running operations
17//! - **Configurable**: Flexible configuration for different use cases
18//!
19//! ## Quick Start
20//!
21//! ```rust
22//! use rustywallet_batch::prelude::*;
23//!
24//! // Generate 1000 keys in parallel
25//! let keys = BatchGenerator::new()
26//!     .count(1000)
27//!     .parallel()
28//!     .generate_vec()
29//!     .unwrap();
30//!
31//! println!("Generated {} keys", keys.len());
32//! ```
33//!
34//! ## Streaming Large Batches
35//!
36//! ```rust
37//! use rustywallet_batch::prelude::*;
38//!
39//! // Stream keys without storing all in memory
40//! let stream = BatchGenerator::new()
41//!     .count(1_000_000)
42//!     .generate()
43//!     .unwrap();
44//!
45//! for key in stream.take(100) {
46//!     println!("{}", key.unwrap().to_hex());
47//! }
48//! ```
49//!
50//! ## Memory-Mapped File Output
51//!
52//! ```no_run
53//! use rustywallet_batch::mmap::{MmapBatchGenerator, OutputFormat};
54//!
55//! // Generate keys directly to file
56//! let count = MmapBatchGenerator::new("keys.txt", 1_000_000)
57//!     .format(OutputFormat::Hex)
58//!     .parallel(true)
59//!     .generate()
60//!     .unwrap();
61//!
62//! println!("Generated {} keys to file", count);
63//! ```
64//!
65//! ## Resumable Generation
66//!
67//! ```no_run
68//! use rustywallet_batch::checkpoint::ResumableBatchGenerator;
69//!
70//! // Start or resume generation with checkpoints
71//! let mut generator = ResumableBatchGenerator::new(
72//!     "my-job",
73//!     10_000_000,
74//!     "keys.txt",
75//!     "checkpoint.json",
76//! );
77//!
78//! generator.generate_with_progress(|progress| {
79//!     println!("Progress: {:.1}%", progress);
80//! }).unwrap();
81//! ```
82//!
83//! ## SIMD Optimization
84//!
85//! ```rust
86//! use rustywallet_batch::simd::SimdBatchProcessor;
87//!
88//! // Check SIMD availability
89//! println!("SIMD: {} ({})", 
90//!     SimdBatchProcessor::is_available(),
91//!     SimdBatchProcessor::feature_name()
92//! );
93//!
94//! // Generate with SIMD optimization
95//! let processor = SimdBatchProcessor::new();
96//! let keys = processor.parallel_generate(10_000);
97//! ```
98//!
99//! ## Incremental Key Scanning
100//!
101//! ```rust
102//! use rustywallet_batch::prelude::*;
103//! use rustywallet_keys::prelude::PrivateKey;
104//!
105//! // Scan from a base key
106//! let base = PrivateKey::from_hex(
107//!     "0000000000000000000000000000000000000000000000000000000000000001"
108//! ).unwrap();
109//!
110//! let scanner = KeyScanner::new(base)
111//!     .direction(ScanDirection::Forward);
112//!
113//! for key in scanner.scan_range(10) {
114//!     println!("{}", key.unwrap().to_hex());
115//! }
116//! ```
117//!
118//! ## Configuration Presets
119//!
120//! ```rust
121//! use rustywallet_batch::prelude::*;
122//!
123//! // Fast mode - maximum speed
124//! let config = BatchConfig::fast();
125//!
126//! // Balanced mode - good speed with reasonable memory
127//! let config = BatchConfig::balanced();
128//!
129//! // Memory efficient - minimal memory usage
130//! let config = BatchConfig::memory_efficient();
131//! ```
132
133pub mod checkpoint;
134pub mod config;
135pub mod error;
136pub mod fast_gen;
137pub mod generator;
138pub mod mmap;
139pub mod prelude;
140pub mod scanner;
141pub mod simd;
142pub mod stream;
143
144#[cfg(test)]
145mod tests;
146
147// Re-export main types at crate root
148pub use checkpoint::{Checkpoint, GenerationMode, ResumableBatchGenerator};
149pub use config::BatchConfig;
150pub use error::BatchError;
151pub use fast_gen::{FastKeyGenerator, IncrementalKeyGenerator};
152pub use generator::BatchGenerator;
153pub use mmap::{MmapBatchGenerator, MmapWriter, OutputFormat};
154pub use scanner::{KeyScanner, ScanDirection};
155pub use simd::SimdBatchProcessor;
156pub use stream::KeyStream;