最近采用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."}
...
```

 

最新文章

  1. javascript中的原型和继承
  2. Centos7上搭建OpenvpnServer——pritunl
  3. .gitignore的多级目录配置
  4. h5上传图片
  5. SignalR一个集成的客户端与服务器库。内部的两个对象类:PersistentConnection和Hub
  6. myeclipse中运行tomcat报错java.lang.NoClassDefFoundError
  7. [工作积累] Android system dialog with native callback
  8. 基于anyrtc的sdk实现直播连麦互动
  9. springmvc 接收对象 滴灌摘要
  10. Eval()、XPath() 和 Bind() 这类数据绑定方法只能在数据绑定控件的上下文中使用
  11. MySql学习(七) —— 查询性能优化 深入理解MySql如何执行查询
  12. 这是个巧妙的表达式: a ˆ= b ˆ= a ˆ= b 它不需要临时变量就可 以交换 a 和 b 的值。
  13. Android多点触摸缩放图片-android学习之旅(四)
  14. SWING中文件的上传
  15. Python 防止mysql 注入的两种方式
  16. 替换php remi源
  17. JS常见的小代码
  18. java-信息安全(十五)-单向认证
  19. Http post/get
  20. Sql Server Report Service 的部署问题(Reporting Service 2014為什麼不需要IIS就可以運行)

热门文章

  1. oc中调用c函数 实现将字符串转换成unsigned char
  2. OSGI 生命周期
  3. UILabel总结
  4. 基于阿里云ecs(centos 7) 安装jenkins
  5. JS - 获取当前的时间,并且转换成年 - 月 - 日格式!
  6. web端 - 返回上一步,点击返回,跳转上个页面 JS
  7. js--生成器总结
  8. 特定场景下的PLC 远程控制和数据读取
  9. ASP.NET Web API路由解析
  10. C#ADO.NET技术总结