This file contains hidden or 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 Block { | |
constructor() { | |
this.index = 0 | |
this.previousHash = "" | |
this.hash = "" | |
this.nonce = 0 | |
this.transactions = [] |
This file contains hidden or 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 { | |
constructor(genesisBlock) { | |
this.blocks = [] | |
} | |
} |
This file contains hidden or 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
addTransaction(transaction) { | |
this.transactions.push(transaction) | |
} |
This file contains hidden or 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
get key() { | |
return JSON.stringify(this.transactions) + this.index + this.previousHash + this.nonce | |
} |
This file contains hidden or 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
let Block = require('./block') | |
let sha256 = require('js-sha256') | |
class Blockchain { | |
constructor(genesisBlock) { | |
this.blocks = [] | |
this.addBlock(genesisBlock) |
This file contains hidden or 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
let Block = require('./models/block') | |
let Transaction = require('./models/transaction') | |
let Blockchain = require('./models/blockchain') | |
// create genesis block | |
let genesisBlock = new Block() | |
let blockchain = new Blockchain(genesisBlock) | |
// create a transaction |
This file contains hidden or 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
private func registerGestureRecognizers() { | |
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(tapped)) | |
self.sceneView.addGestureRecognizer(tapGestureRecognizer) | |
} |
This file contains hidden or 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
@objc func tapped(recognizer :UIGestureRecognizer) { | |
guard let currentFrame = self.sceneView.session.currentFrame else { | |
return | |
} | |
let videoNode = SKVideoNode(fileNamed: "big_buck_bunny.mp4") | |
videoNode.play() | |
let skScene = SKScene(size: CGSize(width: 640, height: 480)) |
This file contains hidden or 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
let addFloodButton = UIButton(frame: CGRect.zero) | |
addFloodButton.setImage(UIImage(named: "plus-image"), for: .normal) | |
addFloodButton.addTarget(self, action: #selector(addFloodAnnotation), for: .touchUpInside) | |
addFloodButton.translatesAutoresizingMaskIntoConstraints = false | |
self.view.addSubview(addFloodButton) | |
addFloodButton.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true |
This file contains hidden or 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 | |
import UIKit | |
extension UIButton { | |
static func buttonForAddingAnnotation() -> UIButton { | |
let addFloodButton = UIButton(frame: CGRect.zero) | |
addFloodButton.translatesAutoresizingMaskIntoConstraints = false | |
addFloodButton.setImage(UIImage(named: "plus-image"), for: .normal) |