mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix code
This commit is contained in:
parent
269a6d1379
commit
0b3ad9262c
@ -32,7 +32,7 @@ become the new richest.
|
|||||||
address public richest;
|
address public richest;
|
||||||
uint public mostSent;
|
uint public mostSent;
|
||||||
|
|
||||||
mapping (address => uint) pending;
|
mapping (address => uint) pendingWithdrawals;
|
||||||
|
|
||||||
function WithdrawalContract() {
|
function WithdrawalContract() {
|
||||||
richest = msg.sender;
|
richest = msg.sender;
|
||||||
@ -41,7 +41,7 @@ become the new richest.
|
|||||||
|
|
||||||
function becomeRichest() returns (bool) {
|
function becomeRichest() returns (bool) {
|
||||||
if (msg.value > mostSent) {
|
if (msg.value > mostSent) {
|
||||||
pending[richest] = msg.value;
|
pendingWithdrawals[richest] += msg.value;
|
||||||
richest = msg.sender;
|
richest = msg.sender;
|
||||||
mostSent = msg.value;
|
mostSent = msg.value;
|
||||||
return true;
|
return true;
|
||||||
@ -52,10 +52,10 @@ become the new richest.
|
|||||||
}
|
}
|
||||||
|
|
||||||
function withdraw() {
|
function withdraw() {
|
||||||
uint amount = pending[msg.sender];
|
uint amount = pendingWithdrawals[msg.sender];
|
||||||
// Remember to zero the pending refund before sending
|
// Remember to zero the pending refund before
|
||||||
// to prevent re-entrancy attacks
|
// sending to prevent re-entrancy attacks
|
||||||
pending[msg.sender] = 0;
|
pendingWithdrawals[msg.sender] = 0;
|
||||||
if (!msg.sender.send(amount)) {
|
if (!msg.sender.send(amount)) {
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user