Basic concept of blockchain
This commit is contained in:
@@ -8,5 +8,25 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
print("Hello, World!")
|
||||
let blockchain = Blockchain()
|
||||
var command: String?
|
||||
|
||||
blockchain.createGenesisBlock(data: "")
|
||||
|
||||
repeat {
|
||||
print("Enter command:")
|
||||
command = readLine()
|
||||
|
||||
if command == "create" {
|
||||
print("data for the new block:")
|
||||
let data = readLine()
|
||||
blockchain.createBlock(data: data ?? "")
|
||||
}
|
||||
|
||||
if command == "spam" {
|
||||
for _ in 1...1000000 {
|
||||
blockchain.createBlock(data: "\((blockchain.chain.last?.index ?? 0)+1)")
|
||||
}
|
||||
}
|
||||
|
||||
} while command != "exit"
|
||||
|
||||
Reference in New Issue
Block a user