Last active
May 14, 2020 10:26
-
-
Save KardanovIR/77544d0b2e835d4b6f9f9d4d8aa09533 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@Callable(i) | |
func registerAsOracle(dataType: String) = { | |
let neededKey = i.callerPublicKey.toBase58String() + "_" + dataType | |
let ratingKey = i.callerPublicKey.toBase58String() + "_rating" | |
let currentRating = match getInteger(this, ratingKey) { | |
case v: Int => v | |
case _ => 100 | |
} | |
match (getString(i.caller, neededKey)) { | |
case data:String => throw("This oracle is registered already") | |
case _ => { | |
[ | |
StringEntry(neededKey, toString(height)), | |
IntegerEntry(ratingKey, currentRating) | |
] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment