Files
SwiftChain/Sources/Blockchain/main.swift
2020-03-01 02:23:06 +01:00

33 lines
672 B
Swift

//
// main.swift
// Blockchain
//
// Created by Victor BODINAUD on 27/02/2020.
// Copyright © 2020 Victor BODINAUD. All rights reserved.
//
import Foundation
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...1000 {
blockchain.createBlock(data: "\((blockchain.chain.last?.index ?? 0)+1)")
}
}
} while command != "exit"