Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Created April 8, 2018 18:34
Show Gist options
  • Save azamsharp/bec75507e921dddbe6e68ea5e2848225 to your computer and use it in GitHub Desktop.
Save azamsharp/bec75507e921dddbe6e68ea5e2848225 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