Skip to content

Instantly share code, notes, and snippets.

@KardanovIR
Created May 13, 2020 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KardanovIR/c52f4d72a7440cd239f91b07c56789d1 to your computer and use it in GitHub Desktop.
Save KardanovIR/c52f4d72a7440cd239f91b07c56789d1 to your computer and use it in GitHub Desktop.
@Callable(i)
func getResult(id: String) = {
if (keyIsDefined(id) == false) then throwIdError(id) else {
let responsesCount = getResponsesCount(id)
let minResponsesCount = getMinResponsesCount(id)
if (responsesCount < minResponsesCount) then throw("Minimum oracles count not reached yet") else {
let result = calculateResult(id)
let ratingsDiff = getOracleRatingsDiff(id, result)
let resultKey = keyResult(id)
let resultDataEntry = StringEntry(resultKey, result)
let dataToWrite = cons(resultDataEntry, ratingsDiff)
dataToWrite
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment