Remove throw from withdrawal pattern

This commit is contained in:
Denton Liu 2016-08-18 12:56:39 -04:00
parent 0b3ad9262c
commit e27493aa83

View File

@ -51,13 +51,17 @@ become the new richest.
}
}
function withdraw() {
function withdraw() returns (bool) {
uint amount = pendingWithdrawals[msg.sender];
// Remember to zero the pending refund before
// sending to prevent re-entrancy attacks
pendingWithdrawals[msg.sender] = 0;
if (!msg.sender.send(amount)) {
throw;
if (msg.sender.send(amount)) {
return true;
}
else {
pendingWithdrawals[msg.sender] = amount;
return false;
}
}
}