项目作者: devxoul

项目描述 :
A blockchain simulator written in Swift
高级语言: Swift
项目地址: git://github.com/devxoul/Blockchain.git
创建时间: 2018-01-14T18:59:28Z
项目社区:https://github.com/devxoul/Blockchain

开源协议:MIT License

下载


Blockchain

A blockchain simulator written in Swift. It simulates full nodes in a virtual network. The nodes mine blocks for about every 10 seconds and verify randomly created transactions.

⚠️ This project is not an actual blockchain implementation. I am very new to the blockchain and the purpose of this repository is to share what I’ve learned. Note that there might be a lot of wrong implementations.

Getting Started

  1. $ git clone https://github.com/devxoul/Blockchain.git
  2. $ cd Blockchain
  3. $ swift run

Then you’ll see:

  1. Run server: Blockchain.Node on address 1.1.1.1
  2. Run server: Blockchain.Node on address 2.2.2.2
  3. Run server: Blockchain.Node on address 3.3.3.3
  4. [Node@2.2.2.2] Connect node 1.1.1.1
  5. [Node@3.3.3.3] Connect node 1.1.1.1
  6. [Node@1.1.1.1] Connect node 2.2.2.2
  7. [Node@3.3.3.3] Connect node 2.2.2.2
  8. [Node@2.2.2.2] Connect node 3.3.3.3
  9. [Node@1.1.1.1] Connect node 3.3.3.3
  10. [Node@2.2.2.2] Create transaction: <Transaction (89.0) 7695f853dccd7c29 -> ed99e0099751256d>
  11. [Node@1.1.1.1] Create transaction: <Transaction (89.0) 7695f853dccd7c29 -> ed99e0099751256d>
  12. [Node@3.3.3.3] Create transaction: <Transaction (89.0) 7695f853dccd7c29 -> ed99e0099751256d>
  13. [Node@3.3.3.3] Create transaction: <Transaction (5.0) 7695f853dccd7c29 -> 715e3b2f5d0dea50>
  14. [Node@1.1.1.1] Create transaction: <Transaction (5.0) 7695f853dccd7c29 -> 715e3b2f5d0dea50>
  15. [Node@2.2.2.2] Create transaction: <Transaction (5.0) 7695f853dccd7c29 -> 715e3b2f5d0dea50>
  16. [Node@3.3.3.3] Submit block: <Block height=1 bits=E600FFFF nonce=1159 transactions=2>
  17. [Node@2.2.2.2] Submit block: <Block height=1 bits=E600FFFF nonce=1159 transactions=2>
  18. [Node@1.1.1.1] Submit block: <Block height=1 bits=E600FFFF nonce=1159 transactions=2>
  19. [Node@1.1.1.1] Submit block: <Block height=1 bits=E600FFFF nonce=1159 transactions=2>
  20. [Node@1.1.1.1] Create transaction: <Transaction (2.0) 8a7b4aa02b4169d3 -> e341e6db66aff49d>
  21. [Node@2.2.2.2] Create transaction: <Transaction (2.0) 8a7b4aa02b4169d3 -> e341e6db66aff49d>
  22. [Node@3.3.3.3] Create transaction: <Transaction (2.0) 8a7b4aa02b4169d3 -> e341e6db66aff49d>
  23. [Node@3.3.3.3] Submit block: <Block height=2 bits=E600FFFF nonce=162 transactions=1>
  24. [Node@2.2.2.2] Submit block: <Block height=2 bits=E600FFFF nonce=162 transactions=1>
  25. [Node@1.1.1.1] Submit block: <Block height=2 bits=E600FFFF nonce=162 transactions=1>
  26. [Node@1.1.1.1] Submit block: <Block height=2 bits=E600FFFF nonce=162 transactions=1>

Development

  1. $ swift package generate-xcodeproj

License

Blockchain is under MIT license. See the LICENSE file for more info.