Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Created April 8, 2018 18:34
Show Gist options
  • Save azamsharp/141e5b0dd1f652ef01a4d782dee9e925 to your computer and use it in GitHub Desktop.
Save azamsharp/141e5b0dd1f652ef01a4d782dee9e925 to your computer and use it in GitHub Desktop.
class DrivingRecordSmartContract : Codable {
func apply(transaction :Transaction, allBlocks :[Block]) {
allBlocks.forEach { block in
block.transactions.forEach { trans in
if trans.driverLicenseNumber == transaction.driverLicenseNumber {
transaction.noOfVoilations += 1
}
if transaction.noOfVoilations > 5 {
transaction.isDrivingLicenseSuspended = true
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment