Skip to content

Commit

Permalink
feat(libs): add ResultErrorCodes helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiaz committed Jan 24, 2024
1 parent 9713d61 commit 6917348
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions contracts/libs/Witnet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,36 @@ library Witnet {
UnhandledIntercept
}

function isCircumstantial(ResultErrorCodes self) internal pure returns (bool) {
return (self == ResultErrorCodes.CircumstantialFailure);
}

function lackOfConsensus(ResultErrorCodes self) internal pure returns (bool) {
return (
self == ResultErrorCodes.InsufficientCommits
|| self == ResultErrorCodes.InsufficientMajority
|| self == ResultErrorCodes.InsufficientQuorum
);
}

function isRetriable(ResultErrorCodes self) internal pure returns (bool) {
return (
lackOfConsensus(self)
|| isCircumstantial(self)
|| poorIncentives(self)
);
}

function poorIncentives(ResultErrorCodes self) internal pure returns (bool) {
return (
self == ResultErrorCodes.OversizedTallyResult
|| self == ResultErrorCodes.InsufficientCommits
|| self == ResultErrorCodes.BridgePoorIncentives
|| self == ResultErrorCodes.BridgeOversizedTallyResult
);
}


/// Possible Radon data request methods that can be used within a Radon Retrieval.
enum RadonDataRequestMethods {
/* 0 */ Unknown,
Expand Down

0 comments on commit 6917348

Please sign in to comment.