mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #913 from chriseth/auction
Updated the function withdraw() in the SimpleAuction and BlindAuction…
This commit is contained in:
commit
c2665dc2fe
@ -280,14 +280,21 @@ activate themselves.
|
||||
}
|
||||
|
||||
/// Withdraw a bid that was overbid.
|
||||
function withdraw() {
|
||||
function withdraw() returns (bool) {
|
||||
var amount = pendingReturns[msg.sender];
|
||||
// It is important to set this to zero because the recipient
|
||||
// can call this function again as part of the receiving call
|
||||
// before `send` returns.
|
||||
pendingReturns[msg.sender] = 0;
|
||||
if (!msg.sender.send(amount))
|
||||
throw; // If anything fails, this will revert the changes above
|
||||
if (amount > 0) {
|
||||
// It is important to set this to zero because the recipient
|
||||
// can call this function again as part of the receiving call
|
||||
// before `send` returns.
|
||||
pendingReturns[msg.sender] = 0;
|
||||
|
||||
if (!msg.sender.send(amount)) {
|
||||
// No need to call throw here, just reset the amount owing
|
||||
pendingReturns[msg.sender] = amount;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// End the auction and send the highest bid
|
||||
@ -491,15 +498,22 @@ high or low invalid bids.
|
||||
}
|
||||
|
||||
/// Withdraw a bid that was overbid.
|
||||
function withdraw() {
|
||||
function withdraw() returns (bool) {
|
||||
var amount = pendingReturns[msg.sender];
|
||||
// It is important to set this to zero because the recipient
|
||||
// can call this function again as part of the receiving call
|
||||
// before `send` returns (see the remark above about
|
||||
// conditions -> effects -> interaction).
|
||||
pendingReturns[msg.sender] = 0;
|
||||
if (!msg.sender.send(amount))
|
||||
throw; // If anything fails, this will revert the changes above
|
||||
if (amount > 0) {
|
||||
// It is important to set this to zero because the recipient
|
||||
// can call this function again as part of the receiving call
|
||||
// before `send` returns (see the remark above about
|
||||
// conditions -> effects -> interaction).
|
||||
pendingReturns[msg.sender] = 0;
|
||||
|
||||
if (!msg.sender.send(amount)){
|
||||
// No need to call throw here, just reset the amount owing
|
||||
pendingReturns[msg.sender] = amount;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// End the auction and send the highest bid
|
||||
|
Loading…
Reference in New Issue
Block a user