Skip to content

Commit

Permalink
all if throw's converted to requires
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamJLemmon committed Nov 20, 2017
1 parent 93638f5 commit 8d16ad6
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions oraclizeAPI_0.4.sol
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ contract usingOraclize {
}

function oraclize_newRandomDSQuery(uint _delay, uint _nbytes, uint _customGasLimit) internal returns (bytes32){
if ((_nbytes == 0)||(_nbytes > 32)) throw;
require((_nbytes != 0) && (_nbytes <= 32));
bytes memory nbytes = new bytes(1);
nbytes[0] = byte(_nbytes);
bytes memory unonce = new bytes(32);
Expand Down Expand Up @@ -853,10 +853,10 @@ contract usingOraclize {

modifier oraclize_randomDS_proofVerify(bytes32 _queryId, string _result, bytes _proof) {
// Step 1: the prefix has to match 'LP\x01' (Ledger Proof version 1)
if ((_proof[0] != "L")||(_proof[1] != "P")||(_proof[2] != 1)) throw;
require((_proof[0] == "L") && (_proof[1] == "P") && (_proof[2] == 1));

bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName());
if (proofVerified == false) throw;
require(proofVerified);

_;
}
Expand Down Expand Up @@ -935,10 +935,8 @@ contract usingOraclize {
function copyBytes(bytes from, uint fromOffset, uint length, bytes to, uint toOffset) internal returns (bytes) {
uint minLength = length + toOffset;

if (to.length < minLength) {
// Buffer too small
throw; // Should be a better way?
}
// Buffer too small
require(to.length >= minLength); // Should be a better way?

// NOTE: the offset 32 is added to skip the `size` field of both bytes variables
uint i = 32 + fromOffset;
Expand Down

0 comments on commit 8d16ad6

Please sign in to comment.