mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #7313 from ethereum/chriseth-patch-1
[DOCS] Protection to not lose money.
This commit is contained in:
commit
a82fbf7322
@ -41,15 +41,11 @@ become the new richest.
|
|||||||
mostSent = msg.value;
|
mostSent = msg.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function becomeRichest() public payable returns (bool) {
|
function becomeRichest() public payable {
|
||||||
if (msg.value > mostSent) {
|
require(msg.value > mostSent, "Not enough money sent.");
|
||||||
pendingWithdrawals[richest] += msg.value;
|
pendingWithdrawals[richest] += msg.value;
|
||||||
richest = msg.sender;
|
richest = msg.sender;
|
||||||
mostSent = msg.value;
|
mostSent = msg.value;
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function withdraw() public {
|
function withdraw() public {
|
||||||
@ -76,16 +72,12 @@ This is as opposed to the more intuitive sending pattern:
|
|||||||
mostSent = msg.value;
|
mostSent = msg.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function becomeRichest() public payable returns (bool) {
|
function becomeRichest() public payable {
|
||||||
if (msg.value > mostSent) {
|
require(msg.value > mostSent, "Not enough money sent.");
|
||||||
// This line can cause problems (explained below).
|
// This line can cause problems (explained below).
|
||||||
richest.transfer(msg.value);
|
richest.transfer(msg.value);
|
||||||
richest = msg.sender;
|
richest = msg.sender;
|
||||||
mostSent = msg.value;
|
mostSent = msg.value;
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user