基于GO语言的PBFT共识算法
最近采用GO语言实现了一个PBFT共识算法的demo,主要用于展示算法的核心逻辑
github地址:https://github.com/w3liu/consensus/tree/master/pbft
1. 主节点定时出块(每1秒钟)
2. 共识流程:
* propose - 主节点提议
* vote - 从节点投票
* preCommit - 所有节点预提交
* commit - 提交,流程结束,进入下一个区块
3. 编译
```
make clean
make
```
4. 启动主节点
```
./pbft -c=./config/config.toml
```
5. 启动从节点
```
./pbft -c=./config/config1.toml
./pbft -c=./config/config2.toml
./pbft -c=./config/config3.toml
```
6. 输出
```
{"level":"info","ts":1600916693.3426318,"caller":"log/zap.go:20","msg":"block commit","height":1,"data":"This is a block data, height is 1."}
{"level":"info","ts":1600916703.341808,"caller":"log/zap.go:20","msg":"block commit","height":2,"data":"This is a block data, height is 2."}
{"level":"info","ts":1600916713.339083,"caller":"log/zap.go:20","msg":"block commit","height":3,"data":"This is a block data, height is 3."}
{"level":"info","ts":1600916723.3332858,"caller":"log/zap.go:20","msg":"block commit","height":4,"data":"This is a block data, height is 4."}
{"level":"info","ts":1600916733.341336,"caller":"log/zap.go:20","msg":"block commit","height":5,"data":"This is a block data, height is 5."}
...
```
最新文章
- javascript中的原型和继承
- Centos7上搭建OpenvpnServer——pritunl
- .gitignore的多级目录配置
- h5上传图片
- SignalR一个集成的客户端与服务器库。内部的两个对象类:PersistentConnection和Hub
- myeclipse中运行tomcat报错java.lang.NoClassDefFoundError
- [工作积累] Android system dialog with native callback
- 基于anyrtc的sdk实现直播连麦互动
- springmvc 接收对象 滴灌摘要
- Eval()、XPath() 和 Bind() 这类数据绑定方法只能在数据绑定控件的上下文中使用
- MySql学习(七) —— 查询性能优化 深入理解MySql如何执行查询
- 这是个巧妙的表达式: a ˆ= b ˆ= a ˆ= b 它不需要临时变量就可 以交换 a 和 b 的值。
- Android多点触摸缩放图片-android学习之旅(四)
- SWING中文件的上传
- Python 防止mysql 注入的两种方式
- 替换php remi源
- JS常见的小代码
- java-信息安全(十五)-单向认证
- Http post/get
- Sql Server Report Service 的部署问题(Reporting Service 2014為什麼不需要IIS就可以運行)