# mini-chain **Repository Path**: nsearchf/mini-chain ## Basic Information - **Project Name**: mini-chain - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2025-05-27 - **Last Updated**: 2025-05-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 1 概述 ## 1.1 目的 - 通过实现一个简单的区块链,来加深对区块链运行机制的理解; - 练习使用 Rust 开发的能力。 ## 1.2 细节实现参考 - 区块链的细节实现参考了 Bitcoin v0.3.0 的 C++ [源码](https://github.com/bitcoin/bitcoin/releases/tag/v0.3)。 ## 1.3 实现的主要功能 - 提供 P2P 节点发现和同步区块的功能; - 提供创建公私钥对的功能; - 提供发送交易的功能; - 提供交易查询的功能; - 提供余额查询的功能; - 提供挖矿的功能,在任意地址上都可以发起单机挖矿; - 提供基础日志,方便跟踪监视。 # 2 项目结构 ## 2.1 文件夹结构 - mini_block_chain:区块链的顶层代码 - bc_func_api:命令行接口实现 - bc_explorer:web 前端、后端代码 - bc_manager:用于管理区块链各种资源的模块 - bc_consensus:共识模块 - bc_wallet:钱包模块 - bc_lib:基础功能 - bc_p2p:P2P网络 - bc_block_data: 定义了 block, block-index, transaction, transaction-index, misc 的数据库 - bc_db: 对 rocketdb 的简单封装 - bc_util: 定义了实用函数,这些函数只依赖于标准库和第三方库 - bc_base: Blockchain 相关概念的基础抽象 ## 2.2 模块间的依赖关系 ![deps_in_workspace](docs/pics/deps_in_workspace.png) ## 2.3 依赖的主要的第三方库 - tracing:用于日志记录 - serde, bincode:用于序列化与反序列化 - secp256k1, sha2, ripemd, rand:密码学相关的库 - tokio: 异步 IO 库 - rocksdb: Rust 语言的 RocksDB 封装库 - axum: web framework - libp2p: P2P 网络库 # 3 参考资料 ## 3.1 BlockChain 相关资料 - [比特币白皮书](https://bitcoin.org/zh_CN/bitcoin-paper) - Bitcoin Developer Guides [en](https://developer.bitcoin.org/devguide/index.html) [cn](https://bitcoin.org/zh_CN/development) - [Bitcoin Reference](https://developer.bitcoin.org/reference/index.html) - Bitcoin 源码 - [Bitcoin github](https://github.com/bitcoin) - [Rust Bitcoin library](https://github.com/rust-bitcoin/rust-bitcoin) - [Blockchain Explained](https://kauri.io/#communities/Getting%20started%20with%20dapp%20development/blockchain-explained/) - 极客时间的区块链课程 - [深入浅出区块链](https://time.geekbang.org/column/intro/100005701?tab=catalog) - [说透区块链](https://time.geekbang.org/column/intro/100084201?tab=catalog) ## 3.2 Rust 语言相关资料 - Rust 权威指南(现在已出第二版) - 极客时间的 Rust 课程 - [陈天 · Rust 编程第一课](https://time.geekbang.org/column/intro/100085301?tab=catalog) - [Rust 语言从入门到实战](https://time.geekbang.org/column/intro/100626901?tab=catalog) - [张汉东的 Rust 实战课](https://time.geekbang.org/course/intro/100060601?tab=catalog) - [Rust 并发编程实战课](https://time.geekbang.org/column/intro/100953201?tab=catalog)