You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
911 B
30 lines
911 B
pragma solidity ^0.4.24;
|
|
|
|
|
|
/**
|
|
* @title Helps contracts guard against reentrancy attacks.
|
|
* @author Remco Bloemen <remco@2π.com>, Eenae <alexey@mixbytes.io>
|
|
* @dev If you mark a function `nonReentrant`, you should also
|
|
* mark it `external`.
|
|
*/
|
|
contract ReentrancyGuard {
|
|
|
|
/// @dev counter to allow mutex lock with only one SSTORE operation
|
|
uint256 private guardCounter = 1;
|
|
|
|
/**
|
|
* @dev Prevents a contract from calling itself, directly or indirectly.
|
|
* 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 an `external`
|
|
* wrapper marked as `nonReentrant`.
|
|
*/
|
|
modifier nonReentrant() {
|
|
guardCounter += 1;
|
|
uint256 localCounter = guardCounter;
|
|
_;
|
|
require(localCounter == guardCounter);
|
|
}
|
|
|
|
}
|
|
|