Skip to content

Instantly share code, notes, and snippets.

@matiasvillaverde
Created December 18, 2017 15:27
Show Gist options
  • Save matiasvillaverde/b4cd864f5961f89d0baf69de5bd8a06e to your computer and use it in GitHub Desktop.
Save matiasvillaverde/b4cd864f5961f89d0baf69de5bd8a06e to your computer and use it in GitHub Desktop.
struct Block {
init(timestamp: Date, data: String, previousBlockHash: Int) {
self.timestamp = timestamp
self.data = data
self.previousBlockHash = previousBlockHash
// For now lets just get some fields, concatenate them, and calculate a hash
let basicHash = String(previousBlockHash) + data + String(timestamp.timeIntervalSince1970)
hash = basicHash.hashValue
}
let timestamp: Date
let data: String
let previousBlockHash: Int
let hash: Int
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment