blockchain.rs - Chain Logic
Architecture Overview
Key Design Principles
Core Data Structures
// src/blockchain.rs (lines 7-26)
#[derive(Clone)]
pub struct Blockchain {
inner: Arc<Mutex<State>>,
}
struct State {
chain: Vec<Block>,
mempool: Vec<Transaction>,
data_dir: PathBuf,
difficulty: u32,
}
#[derive(Serialize, Deserialize)]
pub struct SyncInfo {
pub height: usize,
pub latest_hash: String,
}Initialization and Persistence
Deterministic Mining Algorithm
Block Construction Process
Mining Process Breakdown
Step
Operation
Deterministic Factor
Peer Synchronization
Chain Replacement Logic
Mempool Management
Thread Safety Implementation
Radio-Optimized Features
Deterministic Block Production
Compact State Management
Error Handling and Recovery
Integration Points
Last updated