aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/abi-spec.rst4
-rw-r--r--docs/contracts.rst22
-rw-r--r--libdevcore/SHA3.h9
3 files changed, 24 insertions, 11 deletions
diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst
index c0969cae..fffd9a2c 100644
--- a/docs/abi-spec.rst
+++ b/docs/abi-spec.rst
@@ -293,9 +293,9 @@ The JSON format for a contract's interface is given by an array of function and/
* `name`: the name of the parameter;
* `type`: the canonical type of the parameter.
- `outputs`: an array of objects similar to `inputs`, can be omitted if function doesn't return anything;
-- `constant`: `true` if function is :ref:`specified to not modify blockchain state <view-functions>`);
- `payable`: `true` if function accepts ether, defaults to `false`;
-- `stateMutability`: a string with one of the following values: `pure` (:ref:`specified to not read blockchain state <pure-functions>`), `view` (same as `constant` above), `nonpayable` and `payable` (same as `payable` above).
+- `stateMutability`: a string with one of the following values: `pure` (:ref:`specified to not read blockchain state <pure-functions>`), `view` (:ref:`specified to not modify the blockchain state <view-functions>`), `nonpayable` and `payable` (same as `payable` above).
+- `constant`: `true` if function is either `pure` or `view`
`type` can be omitted, defaulting to `"function"`.
diff --git a/docs/contracts.rst b/docs/contracts.rst
index 50e7f3d1..ef09d935 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -469,9 +469,20 @@ View Functions
Functions can be declared ``view`` in which case they promise not to modify the state.
+The following statements are considered modifying the state:
+
+#. Writing to state variables.
+#. :ref:`Emitting events. <events>`.
+#. :ref:`Creating other contracts <creating-contracts>`.
+#. Using ``selfdestruct``.
+#. Sending Ether via calls.
+#. Calling any function not marked ``view`` or ``pure``.
+#. Using low-level calls.
+#. Using inline assembly that contains certain opcodes.
+
::
- pragma solidity ^0.4.0;
+ pragma solidity ^0.4.16;
contract C {
function f(uint a, uint b) view returns (uint) {
@@ -496,9 +507,16 @@ Pure Functions
Functions can be declared ``pure`` in which case they promise not to read from or modify the state.
+In addition to the list of state modifying statements explained above, the following are considered reading from the state:
+#. Reading from state variables.
+#. Accessing ``this.balance`` or ``<address>.balance``.
+#. Accessing any of the members of ``block``, ``tx``, ``msg`` (with the exception of ``msg.sig`` and ``msg.data``).
+#. Calling any function not marked ``pure``.
+#. Using inline assembly that contains certain opcodes.
+
::
- pragma solidity ^0.4.0;
+ pragma solidity ^0.4.16;
contract C {
function f(uint a, uint b) pure returns (uint) {
diff --git a/libdevcore/SHA3.h b/libdevcore/SHA3.h
index 1a561066..d1e2cc98 100644
--- a/libdevcore/SHA3.h
+++ b/libdevcore/SHA3.h
@@ -23,8 +23,9 @@
#pragma once
+#include <libdevcore/FixedHash.h>
+
#include <string>
-#include "FixedHash.h"
namespace dev
{
@@ -47,10 +48,4 @@ inline h256 keccak256(std::string const& _input) { return keccak256(bytesConstRe
/// Calculate Keccak-256 hash of the given input (presented as a FixedHash), returns a 256-bit hash.
template<unsigned N> inline h256 keccak256(FixedHash<N> const& _input) { return keccak256(_input.ref()); }
-/// Calculate Keccak-256 hash of the given input, possibly interpreting it as nibbles, and return the hash as a string filled with binary data.
-inline std::string keccak256(std::string const& _input, bool _isNibbles) { return asString((_isNibbles ? keccak256(fromHex(_input)) : keccak256(bytesConstRef(&_input))).asBytes()); }
-
-/// Calculate Keccak-256 MAC
-inline void keccak256mac(bytesConstRef _secret, bytesConstRef _plain, bytesRef _output) { keccak256(_secret.toBytes() + _plain.toBytes()).ref().populate(_output); }
-
}