How dantee-e/cleytocoin works
Project type and purpose
• CleytoCoin is a Rust-based cryptocurrency node project. It provides three command-line binaries:
• CleytoCoin (the main node)
• CleytoCoin-wallet (wallet generation and transactions)
• CleytoCoin-miner (mining operations)
• It implements a Proof of Work consensus, peer-to-peer transaction broadcasting, block creation, and key-pair based wallets.
File structure
• Cargo.toml / Cargo.lock: Rust package configuration & dependencies.
• src/lib.rs: core library exposing chain and wallet functionality.
• src/chain/: domain module containing:
• block.rs – block data structure, header, proof fields
• transaction.rs – transaction structure and serialization
• wallet.rs – key generation and address derivation
• utils.rs – hashing, serialization helpers
• src/chain.rs: likely re-exports or top-level glue for chain module.
• src/TODO.txt: development notes.
• tests/: integration/unit tests covering block creation, chain growth, transaction signing, verification.
README for additional insights
• Describes CLI usage: start node, generate wallet, send transaction, start miner, stop node.
• Emphasizes PoW, P2P, Rust performance.
a. Main components:
1. CLI Interface Layer
– CleytoCoin (node)
– CleytoCoin-wallet (wallet commands)
– CleytoCoin-miner (mining commands)
2. Core Library Layer (src/lib.rs + src/chain)
– Chain Manager (chain.rs)
– Block struct & validation (block.rs)
– Transaction struct & mempool (transaction.rs)
– Wallet/keypair manager (wallet.rs)
– Utilities (hashing, serialization) (utils.rs)
3. Storage Layer
– On-disk blockchain database/files (e.g., flat files in target/release or custom path)
4. Network Layer
– P2P peer connections for broadcasting blocks & transactions
5. Consensus Engine
– PoW algorithm (nonce search loop inside miner)
6. External Interfaces
– User (CLI)
– Other peer nodes
b. Relationships & data flows
1. User issues CLI command → CLI binary
2. CLI binary calls Core Library API
3. Core Library updates Mempool or initiates mining:
– Transaction path: wallet → transaction struct → sign → mempool → network broadcast
– Mining path: consensus engine → block proposal → PoW → block mined → append to chain → persist to storage → network broadcast
4. Network Layer receives incoming blocks/transactions → Core Library for validation → update local chain/mempool → persist as needed
c. Architectural patterns & design principles
• Layered architecture (CLI → core library → storage/network).
• Modular domain components (chain, transaction, wallet, utils).
• Separation of concerns: CLI presentation vs. domain logic vs. persistence vs. network vs. consensus.
• Test harness validating units in isolation (unit and integration tests under tests/).
d. Relevant technologies
• Rust & Cargo (build, dependency management).
• Hashing: SHA256 or custom (utils.rs).
• Serialization: bincode, serde (inferred from utils).
• File-system or simple DB for block persistence.
• Tokio or std::net for P2P sockets (not shown in code but typical in Rust crypto nodes).
Detail
• Sequence: e.g., mining loop → block found → persist → broadcast.
• Versioning notes if needed (Rust version, protocol version in block header).
• Keep labels concise but capture all essential architectural elements.
• Review src/chain utils and wallet code to call out any special hash algorithms or crypto libraries.