aboutsummaryrefslogtreecommitdiffstats
path: root/test/compilationTests/zeppelin/ReentrancyGuard.sol
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-07-05 18:28:15 +0800
committerchriseth <chris@ethereum.org>2017-07-05 18:39:55 +0800
commitac84b36144f746662e5ddb984d283e053c7d06ba (patch)
treef50ee438a384e60574a4c28ea32d2b6ae2315795 /test/compilationTests/zeppelin/ReentrancyGuard.sol
parent05a26fc98c1201057c618c536ca0537e456c9b15 (diff)
downloaddexon-solidity-ac84b36144f746662e5ddb984d283e053c7d06ba.tar.gz
dexon-solidity-ac84b36144f746662e5ddb984d283e053c7d06ba.tar.zst
dexon-solidity-ac84b36144f746662e5ddb984d283e053c7d06ba.zip
Added various contracts for testing.
Diffstat (limited to 'test/compilationTests/zeppelin/ReentrancyGuard.sol')
-rw-r--r--test/compilationTests/zeppelin/ReentrancyGuard.sol34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/compilationTests/zeppelin/ReentrancyGuard.sol b/test/compilationTests/zeppelin/ReentrancyGuard.sol
new file mode 100644
index 00000000..ca8b643b
--- /dev/null
+++ b/test/compilationTests/zeppelin/ReentrancyGuard.sol
@@ -0,0 +1,34 @@
+pragma solidity ^0.4.11;
+
+/**
+ * @title Helps contracts guard agains rentrancy attacks.
+ * @author Remco Bloemen <remco@2π.com>
+ * @notice If you mark a function `nonReentrant`, you should also
+ * mark it `external`.
+ */
+contract ReentrancyGuard {
+
+ /**
+ * @dev We use a single lock for the whole contract.
+ */
+ bool private rentrancy_lock = false;
+
+ /**
+ * @dev Prevents a contract from calling itself, directly or indirectly.
+ * @notice If you mark a function `nonReentrant`, you should also
+ * mark it `external`. Calling one nonReentrant function from
+ * another is not supported. Instead, you can implement a
+ * `private` function doing the actual work, and a `external`
+ * wrapper marked as `nonReentrant`.
+ */
+ modifier nonReentrant() {
+ if(rentrancy_lock == false) {
+ rentrancy_lock = true;
+ _;
+ rentrancy_lock = false;
+ } else {
+ throw;
+ }
+ }
+
+}