aboutsummaryrefslogtreecommitdiffstats
path: root/docs/common-patterns.rst
diff options
context:
space:
mode:
authorDenton Liu <liu.denton+github@gmail.com>2016-08-19 00:56:39 +0800
committerDenton Liu <liu.denton+github@gmail.com>2016-08-19 00:56:39 +0800
commite27493aa8306da65d4cfc464b7867f1faaf72a9f (patch)
treece22ca6273d4e28a23858d1c02f3462d37271912 /docs/common-patterns.rst
parent0b3ad9262cd99ae4788e14f399905952c16d5d27 (diff)
downloaddexon-solidity-e27493aa8306da65d4cfc464b7867f1faaf72a9f.tar.gz
dexon-solidity-e27493aa8306da65d4cfc464b7867f1faaf72a9f.tar.zst
dexon-solidity-e27493aa8306da65d4cfc464b7867f1faaf72a9f.zip
Remove throw from withdrawal pattern
Diffstat (limited to 'docs/common-patterns.rst')
-rw-r--r--docs/common-patterns.rst10
1 files changed, 7 insertions, 3 deletions
diff --git a/docs/common-patterns.rst b/docs/common-patterns.rst
index 6302af72..12c6f20c 100644
--- a/docs/common-patterns.rst
+++ b/docs/common-patterns.rst
@@ -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;
}
}
}