78
从零出发,用Python开发一个小型的区块链程序
source link: http://blockchain.51cto.com/art/201806/576346.htm?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
背景
“区块链”是什么?
关于该应用程序
1.将事务存储到区块中
2.让区块不可更改
3.链接区块
清单 1. 我们的 Blockchain 类的初始结构
这是我们的 Blockchain 类:
4.实现工作量证明算法
请注意,没有明确的逻辑来快速确定随机数;只能通过暴力破解。
5.将区块添加到链中
挖矿
OK,基本工作已经完成了。
6.创建接口
7.建立共识和去中心化
8.构建应用程序
9.运行应用程序
完工了!
- 尝试发布一些数据,您会看到类似下图的结果:
- 单击 Request to mine 按钮,您会看到类似下图的结果:
- 单击 Resync 按钮,您会看到应用程序与链重新同步:
验证事务
结束
最后的最后,需要源代码的私信回复“区块链”
原文链接:https://wwww.ibm.com/developerworks/cn/cloud/library/cl-develop-blockchain-app-in-python/index.htm
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK