Skip to content

Instantly share code, notes, and snippets.

@KardanovIR
Last active May 14, 2020 10:26
Show Gist options
  • Save KardanovIR/77544d0b2e835d4b6f9f9d4d8aa09533 to your computer and use it in GitHub Desktop.
Save KardanovIR/77544d0b2e835d4b6f9f9d4d8aa09533 to your computer and use it in GitHub Desktop.
@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