mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
More code-style corrections
This commit is contained in:
parent
0a37072e4c
commit
8bbe99ad11
@ -84,7 +84,8 @@ This means that cyclic creation dependencies are impossible.
|
|||||||
// Only the creator can alter the name --
|
// Only the creator can alter the name --
|
||||||
// the comparison is possible since contracts
|
// the comparison is possible since contracts
|
||||||
// are implicitly convertible to addresses.
|
// are implicitly convertible to addresses.
|
||||||
if (msg.sender == creator) name = newName;
|
if (msg.sender == creator)
|
||||||
|
name = newName;
|
||||||
}
|
}
|
||||||
|
|
||||||
function transfer(address newOwner) {
|
function transfer(address newOwner) {
|
||||||
@ -221,7 +222,11 @@ The next example is a bit more complex:
|
|||||||
::
|
::
|
||||||
|
|
||||||
contract complex {
|
contract complex {
|
||||||
struct Data { uint a; bytes3 b; mapping(uint => uint) map; }
|
struct Data {
|
||||||
|
uint a;
|
||||||
|
bytes3 b;
|
||||||
|
mapping (uint => uint) map;
|
||||||
|
}
|
||||||
mapping (uint => mapping(bool => Data[])) public data;
|
mapping (uint => mapping(bool => Data[])) public data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,7 +265,11 @@ inheritable properties of contracts and may be overridden by derived contracts.
|
|||||||
// This means that if the owner calls this function, the
|
// This means that if the owner calls this function, the
|
||||||
// function is executed and otherwise, an exception is
|
// function is executed and otherwise, an exception is
|
||||||
// thrown.
|
// thrown.
|
||||||
modifier onlyowner { if (msg.sender != owner) throw; _ }
|
modifier onlyowner {
|
||||||
|
if (msg.sender != owner)
|
||||||
|
throw;
|
||||||
|
_
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -277,17 +286,24 @@ inheritable properties of contracts and may be overridden by derived contracts.
|
|||||||
|
|
||||||
contract priced {
|
contract priced {
|
||||||
// Modifiers can receive arguments:
|
// Modifiers can receive arguments:
|
||||||
modifier costs(uint price) { if (msg.value >= price) _ }
|
modifier costs(uint price) {
|
||||||
|
if (msg.value >= price) {
|
||||||
|
_
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract Register is priced, owned {
|
contract Register is priced, owned {
|
||||||
mapping (address => bool) registeredAddresses;
|
mapping (address => bool) registeredAddresses;
|
||||||
uint price;
|
uint price;
|
||||||
|
|
||||||
function Register(uint initialPrice) { price = initialPrice; }
|
function Register(uint initialPrice) { price = initialPrice; }
|
||||||
|
|
||||||
function register() costs(price) {
|
function register() costs(price) {
|
||||||
registeredAddresses[msg.sender] = true;
|
registeredAddresses[msg.sender] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function changePrice(uint _price) onlyowner {
|
function changePrice(uint _price) onlyowner {
|
||||||
price = _price;
|
price = _price;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user