# blockchain
**Repository Path**: atime/blockchain
## Basic Information
- **Project Name**: blockchain
- **Description**: Python3.6 + Tornado5.0简单实现区块链
- **Primary Language**: Python
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 1
- **Created**: 2021-09-12
- **Last Updated**: 2021-09-12
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Blockchain
基于Python3区块链简单实现
# 使用手册
### 1、系统和软件要求
操作系统: Linux/Macosx
软件版本: Python 3.6,执行pip install -r requirements.txt安装所需模块
### 2、config.conf说明
name = Blockchain 服务器名
port = 8100 默认端口
processes = 1 多进程,多个进程共用一个端口
_debug = True 调试模式
_autoreload = True修改py脚本是否重新载入
### 3、启动和暂停服务
默认启动: python app.py加载config.conf配置文件的默认端口
启动: python app.py --port=8100(指定端口启动)
暂停: kill `cat server.pid`适用于在当前目录启动单个程序,如有多个则手动kill
### 4、API使用说明
1、启动两个端口(测试是在同一台电脑)
python app.py --port=8100,声明node1代表服务器1,供后面说明使用
python app.py --port=8101,声明node2代表服务器2,供后面说明使用
2、添加节点URL http://node1/api/node/register Method=POST
向node2添加node1节点的参数:{"nodes": ["http://127.0.0.1:8100"]}
向node1添加node2节点的参数:{"nodes": ["http://127.0.0.1:8101"]}
3、解决节点冲突URL http://node1/api/node/resolve Method=GET
4、获取所有节点URL http://node1/api/node/list Method=GET
5、创建交易URL http://node1/api/transaction/new Method=POST
向node1创建一个交易的参数(a向b转账5):{"sender": "a", "recipient": "b", "amount": 5}
6、挖矿接口URL http://node1/api/chain/mine Method=GET
7、新节点同步数据URL http://node1/api/chain/sync Method=GET
8、新增广播接口,交易/验证新的块/新增节点这些条件会触发广播机制,各个节点接收广播并传达广播