This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// CountDownTimer.swift | |
// | |
// Created by Harsh Vishwakarma. | |
// | |
import Foundation | |
import UIKit | |
final class CountDownTimer: NSObject, CountDown { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public typealias CompletionHandler = () -> Void | |
protocol CountDown: NSObjectProtocol { | |
// 1 | |
var timeElapsed: TimeInterval {get set} | |
var timeLimit: TimeInterval {get set} | |
// 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X GET \ | |
http://localhost:5000/chain \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X POST \ | |
http://localhost:5000/transactions/new \ | |
-H 'content-type: application/json' \ | |
-d '{ | |
"sender": "d4ee26eee15148ee92c6cd394edd974e", | |
"recipient": "4as226eee1514743e92c6cd394edd974f", | |
"amount": 5 | |
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X GET \ | |
http://localhost:5000/mine \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X POST \ | |
http://localhost:5000/nodes/register \ | |
-H 'content-type: application/json' \ | |
-d '{ | |
"nodes": ["http://127.0.0.104:5000"] | |
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -X GET \ | |
http://localhost:5000/nodes/resolve \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"info": { | |
"_postman_id": "4378e49e-75dc-4772-be83-27806ad15b2c", | |
"name": "Swift Blockchain", | |
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" | |
}, | |
"item": [ | |
{ | |
"name": "Get Chain", | |
"protocolProfileBehavior": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Blockchain: Chain { | |
// MARK: - Properties | |
... | |
var nodes: Set<String> | |
// MARK: - Initializers | |
init() { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instance of blockchain | |
let blockchain = Blockchain() | |
// Create a new router | |
let router = Router() | |
router.all(middleware: BodyParser()) | |
// Handle HTTP GET requests to / | |
router.get("/") { | |
request, response, next in |