Created
December 18, 2017 15:27
-
-
Save matiasvillaverde/b4cd864f5961f89d0baf69de5bd8a06e to your computer and use it in GitHub Desktop.
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
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