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
public protocol StringRepresentable: CustomStringConvertible { } | |
extension StringRepresentable { | |
public var description: String { | |
Mirror(reflecting: self).children.reduce("") { $0 + ($1.label ?? "").appending(":\($1.value as Any)\n") } | |
} | |
} |
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
use crate::blockchain::Chain; | |
use rocket::*; | |
use rocket_contrib::json::{Json, JsonValue}; | |
use serde::{Deserialize, Serialize}; | |
use std::{sync::Mutex}; | |
use rocket::config::{Config, Environment}; | |
use rocket::response::{Redirect, Response}; | |
use rocket::http::{Status, ContentType}; | |
use std::io::Cursor; |
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
/** | |
Creates a SHA-256 hash of a Block | |
- Parameter block: Block | |
- returns: String | |
*/ | |
pub fn hash(block: &Block) -> String { | |
let json = serde_json::to_string(block).unwrap(); | |
let readable_string = Cursor::new(&json); |
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
/** | |
Creates a new transaction to go into the next mined Block | |
- Parameter sender: Address of the Sender | |
- Parameter recipient: Address of the Recipient | |
- Parameter amount: Amount | |
- returns: The index of the Block that will hold this transaction | |
*/ | |
pub fn new_transaction(&mut self, sender: String, recipient: String, amount: u64) -> u64 { |
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
pub struct Block { | |
index: u64, | |
timestamp: DateTime<Utc>, | |
transactions: Vec<Transaction>, | |
proof: u64, | |
previous_hash: String, | |
} |
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
[package] | |
name = "blockchain" | |
version = "0.1.0" | |
authors = ["Harsh Vishwakarma"] | |
edition = "2018" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
chrono = { version = " 0.4", features = ["serde"] } |
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
// | |
// ConnectorView.swift | |
// Helper | |
// | |
// Created by Harsh 20/08/20. | |
// Copyright © 2020 Harsh. All rights reserved. | |
// | |
import UIKit |
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
// PercentLayoutConstraint.swift | |
import Foundation | |
import UIKit | |
@IBDesignable | |
final class PercentLayoutConstraint: NSLayoutConstraint { | |
@IBInspectable var marginPercent: CGFloat = 0 | |
var screenSize: (width: CGFloat, height: CGFloat) { |
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
// | |
// UIViewController+ShorthandAlerts.swift | |
// | |
// Created by Ayden Panhuyzen on 2017-07-31. | |
// Copyright © 2017-2018 Ayden Panhuyzen. All rights reserved. | |
// https://gist.github.com/aydenp | |
// | |
import UIKit |
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
public typealias CompletionHandler = () -> Void | |
class LiftOffViewController : UIViewController { | |
var countDownTimer: CountDown? | |
@IBOutlet weak var labelTimeLeft: UILabel! | |
override func viewDidLoad() { | |
super.viewDidLoad() |
NewerOlder