首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

300行Kotlin代码实现的区块链

使用Kotlin实现的区块链基本逻辑!

源码地址

GitHub仓库:https://github.com/ivaneye/naivechain

启动方式

启动参数添加 -Dserver.port=8080,启动不同的端口,模拟不同的节点。

假设目前启动了8080和8081两个端口:

通过POST http://localhost:8080/peer 来添加节点的互通。body为peer=ws://localhost:8081/endpoint

添加完成后,8080与8081节点即建立了链接

通过POST http://localhost:8080/block 来添加区块。body为data=11111

参考

A blockchain in 200 lines of code:https://medium.com/@lhartikk/a-blockchain-in-200-lines-of-code-963cc1cc0e54 (需翻墙)

A blockchain in 200 lines of code:http://blog.jobbole.com/110860/(翻译)

js版naivechain:https://github.com/lhartikk/naivechain

Java版naivechain:https://github.com/sunysen/naivechain 有两处逻辑错误

  • 发表于:
  • 原文链接http://kuaibao.qq.com/s/20180311G068G000?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券