* signing prefix added * Minor improvement * Tests changed * Successfully tested * Minor improvements * Minor improvements * Revert "Dangling commas are now required. (#1359)" This reverts commita6889776f4. * updates * fixes #1391 (cherry picked from commitda67e435b1)
34 lines
963 B
Solidity
34 lines
963 B
Solidity
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;
|
|
|
|
constructor() public {
|
|
_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);
|
|
}
|
|
|
|
}
|