mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Corrections and some style.
This commit is contained in:
parent
7e838fd4a8
commit
d58a4e08da
@ -665,7 +665,7 @@ What does the following strange check do in the Custom Token contract?
|
|||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
require(balanceOf[_to] + _value >= balanceOf[_to]);
|
require((balanceOf[_to] + _value) >= balanceOf[_to]);
|
||||||
|
|
||||||
Integers in Solidity (and most other machine-related programming languages) are restricted to a certain range.
|
Integers in Solidity (and most other machine-related programming languages) are restricted to a certain range.
|
||||||
For ``uint256``, this is ``0`` up to ``2**256 - 1``. If the result of some operation on those numbers
|
For ``uint256``, this is ``0`` up to ``2**256 - 1``. If the result of some operation on those numbers
|
||||||
|
@ -137,7 +137,8 @@ Sending and Receiving Ether
|
|||||||
depth, they can force the transfer to fail; take this possibility into account or use ``send`` and make sure to always check its return value. Better yet,
|
depth, they can force the transfer to fail; take this possibility into account or use ``send`` and make sure to always check its return value. Better yet,
|
||||||
write your contract using a pattern where the recipient can withdraw Ether instead.
|
write your contract using a pattern where the recipient can withdraw Ether instead.
|
||||||
3. Sending Ether can also fail because the execution of the recipient contract
|
3. Sending Ether can also fail because the execution of the recipient contract
|
||||||
requires more than the allotted amount of gas (explicitly by using ``revert`` or
|
requires more than the allotted amount of gas (explicitly by using ``require``,
|
||||||
|
``assert``, ``revert``, ``throw`` or
|
||||||
because the operation is just too expensive) - it "runs out of gas" (OOG).
|
because the operation is just too expensive) - it "runs out of gas" (OOG).
|
||||||
If you use ``transfer`` or ``send`` with a return value check, this might provide a
|
If you use ``transfer`` or ``send`` with a return value check, this might provide a
|
||||||
means for the recipient to block progress in the sending contract. Again, the best practice here is to use
|
means for the recipient to block progress in the sending contract. Again, the best practice here is to use
|
||||||
|
@ -94,7 +94,7 @@ of votes.
|
|||||||
// called incorrectly. But watch out, this
|
// called incorrectly. But watch out, this
|
||||||
// will currently also consume all provided gas
|
// will currently also consume all provided gas
|
||||||
// (this is planned to change in the future).
|
// (this is planned to change in the future).
|
||||||
require(msg.sender == chairperson || !voters[voter].voted);
|
require((msg.sender == chairperson) && !voters[voter].voted);
|
||||||
voters[voter].weight = 1;
|
voters[voter].weight = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,11 +268,11 @@ activate themselves.
|
|||||||
|
|
||||||
// Revert the call if the bidding
|
// Revert the call if the bidding
|
||||||
// period is over.
|
// period is over.
|
||||||
require(now < auctionStart + biddingTime);
|
require(now <= auctionStart + biddingTime);
|
||||||
|
|
||||||
// If the bid is not higher, send the
|
// If the bid is not higher, send the
|
||||||
// money back.
|
// money back.
|
||||||
require(msg.value <= highestBid);
|
require(msg.value > highestBid);
|
||||||
|
|
||||||
if (highestBidder != 0) {
|
if (highestBidder != 0) {
|
||||||
// Sending back the money by simply using
|
// Sending back the money by simply using
|
||||||
@ -322,7 +322,7 @@ activate themselves.
|
|||||||
// external contracts.
|
// external contracts.
|
||||||
|
|
||||||
// 1. Conditions
|
// 1. Conditions
|
||||||
require(now >= auctionStart + biddingTime); // auction did not yet end
|
require(now >= (auctionStart + biddingTime)); // auction did not yet end
|
||||||
require(!ended); // this function has already been called
|
require(!ended); // this function has already been called
|
||||||
|
|
||||||
// 2. Effects
|
// 2. Effects
|
||||||
@ -446,11 +446,9 @@ high or low invalid bids.
|
|||||||
onlyBefore(revealEnd)
|
onlyBefore(revealEnd)
|
||||||
{
|
{
|
||||||
uint length = bids[msg.sender].length;
|
uint length = bids[msg.sender].length;
|
||||||
require(
|
require(_values.length == length);
|
||||||
_values.length == length &&
|
require(_fake.length == length);
|
||||||
_fake.length == length &&
|
require(_secret.length == length);
|
||||||
_secret.length == length
|
|
||||||
);
|
|
||||||
|
|
||||||
uint refund;
|
uint refund;
|
||||||
for (uint i = 0; i < length; i++) {
|
for (uint i = 0; i < length; i++) {
|
||||||
@ -609,8 +607,10 @@ Safe Remote Purchase
|
|||||||
// otherwise, the contracts called using `send` below
|
// otherwise, the contracts called using `send` below
|
||||||
// can call in again here.
|
// can call in again here.
|
||||||
state = State.Inactive;
|
state = State.Inactive;
|
||||||
// This actually allows both the buyer and the seller to
|
|
||||||
|
// NOTE: This actually allows both the buyer and the seller to
|
||||||
// block the refund - the withdraw pattern should be used.
|
// block the refund - the withdraw pattern should be used.
|
||||||
|
|
||||||
buyer.transfer(value);
|
buyer.transfer(value);
|
||||||
seller.transfer(this.balance));
|
seller.transfer(this.balance));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user