Skip to content

Instantly share code, notes, and snippets.

View harshvishu's full-sized avatar
🍥
Learning

हर्ष • Harsh • ハラシャ harshvishu

🍥
Learning
View GitHub Profile
//
// CountDownTimer.swift
//
// Created by Harsh Vishwakarma.
//
import Foundation
import UIKit
final class CountDownTimer: NSObject, CountDown {
import Foundation
public typealias CompletionHandler = () -> Void
protocol CountDown: NSObjectProtocol {
// 1
var timeElapsed: TimeInterval {get set}
var timeLimit: TimeInterval {get set}
// 2
@harshvishu
harshvishu / Swift-Blockchain-Chain-Chain.sh
Created January 8, 2019 17:39
Swift-Blockchain-Chain-Chain
curl -X GET \
http://localhost:5000/chain \
@harshvishu
harshvishu / Swift-Blockchain-Chain-NewTransaction.sh
Created January 8, 2019 17:39
Swift-Blockchain-NewTransaction
curl -X POST \
http://localhost:5000/transactions/new \
-H 'content-type: application/json' \
-d '{
"sender": "d4ee26eee15148ee92c6cd394edd974e",
"recipient": "4as226eee1514743e92c6cd394edd974f",
"amount": 5
}'
@harshvishu
harshvishu / Swift-Blockchain-Chain-Mine.sh
Created January 8, 2019 17:38
Swift-Blockchain-Mine
curl -X GET \
http://localhost:5000/mine \
@harshvishu
harshvishu / Swift-Blockchain-NewNode.sh
Created January 8, 2019 17:37
Swift-Blockchain-New-Node
curl -X POST \
http://localhost:5000/nodes/register \
-H 'content-type: application/json' \
-d '{
"nodes": ["http://127.0.0.104:5000"]
}'
@harshvishu
harshvishu / Swift-Blockchain-Chain-Resolve.sh
Created January 8, 2019 17:36
Swift-Blockchain-Curl-Resolve
curl -X GET \
http://localhost:5000/nodes/resolve \
{
"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": {
@harshvishu
harshvishu / Swift-Blockchain-Node.swift
Last active January 8, 2019 15:58
Swift-Blockchain-Node
class Blockchain: Chain {
// MARK: - Properties
...
var nodes: Set<String>
// MARK: - Initializers
init() {
@harshvishu
harshvishu / Swift-Blockchain-API.swift
Last active January 8, 2019 18:10
Swift-Blockchain-Server
// 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