Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Many changes:
Browse files Browse the repository at this point in the history
1. remove ordered_non_unique non-deterministic indices from producer
scheduling
2. added API to return contents of i64 tables
3. updated documentation to reflect deprecation of precondition and
validate
4. remove calls to WASM precondition and validate, but keep them for
native contracts
  • Loading branch information
bytemaster committed Jul 21, 2017
1 parent 8fa97e1 commit a97251d
Show file tree
Hide file tree
Showing 53 changed files with 307 additions and 133 deletions.
14 changes: 7 additions & 7 deletions contracts/currency/currency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ extern "C" {
storeAccount( N(currency), Account( CurrencyTokens(1000ll*1000ll*1000ll) ) );
}

/// The apply method implements the dispatch of events to this contract
void apply( uint64_t code, uint64_t action ) {
if( code == N(currency) ) {
if( action == N(transfer) )
currency::apply_currency_transfer( currentMessage< TOKEN_NAME::Transfer >() );
}
}
/// The apply method implements the dispatch of events to this contract
void apply( uint64_t code, uint64_t action ) {
if( code == N(currency) ) {
if( action == N(transfer) )
currency::apply_currency_transfer( currentMessage< TOKEN_NAME::Transfer >() );
}
}
}
21 changes: 6 additions & 15 deletions contracts/eoslib/contracts.dox
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,22 @@

@subsection programentry Entry Points

EOS.IO applications have three potential starting points that behave like `main` in traditional applications:
EOS.IO applications have a `apply` which is like `main` in traditional applications:

```
extern "C" {
void validate( uint64_t code, uint64_t action );
void precondition( uint64_t code, uint64_t action );
void init();
void apply( uint64_t code, uint64_t action );
}
```

Each of these entry points is give the arguments `code` and `action` which uniquely identify every event in
the system. For example, code could be a `currency` contract and action could be `transfer`. This event (code,action)
`main` is give the arguments `code` and `action` which uniquely identify every event in

This comment has been minimized.

Copy link
@nathanielhourt

nathanielhourt Jul 26, 2017

Contributor

main? Shouldn't this say apply?

the system. For example, `code` could be a *currency* contract and `action` could be *transfer*. This event (code,action)
may be passed to several contracts including the `sender` and `receiver`. It is up to your application to figure
out what to do in response to such an event.

Each handler has a different level of access to blockchain state:

- **validate** can only access the data on the message itself
- **precondition** only has read access to the database and message
- **apply** has read/write access to the database

These three different handlers enable EOS.IO to maximize the amount of potential parallelism possible and it may
make sense to move computationaly expensive validations to either precondition or validate. That said, most developers
can postpone learning about `validate` and `precondition` as anything that can be done in those entry points can also
be performed in `apply`.
`init` is another entry point that is called once immediately after loading the code. It is where you should perform
one-time initialization of state.


### Example Apply Entry Handler
Expand Down
1 change: 1 addition & 0 deletions contracts/eoslib/rpc.dox
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
```
{
"head_block_num":449,
"last_irreversible_block_num": 434,
"head_block_id":"000001c1a0f072a5ca76831ac6c6e2988efcf162e953eb40046ec2ceca817a9f",
"head_block_time":"2017-07-18T21:02:24",
"head_block_producer":"initd",
Expand Down
8 changes: 4 additions & 4 deletions docs/currency_8hpp.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:a0c4afa08ec2e44777543fe547d60e9e6"><td class="memItemLeft" align="right" valign="top">typedef <a class="el" href="structeos_1_1token.html">eos::token</a>&lt; <a class="el" href="types_8h.html#aaa5d1cd013383c889537491c3cfd9aad">uint64_t</a>, <a class="el" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(currency)&gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespace_t_o_k_e_n___n_a_m_e.html#a0c4afa08ec2e44777543fe547d60e9e6">TOKEN_NAME::CurrencyTokens</a></td></tr>
<tr class="separator:a0c4afa08ec2e44777543fe547d60e9e6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a90f15481940a6f47f7f86fe0ab21bda4"><td class="memItemLeft" align="right" valign="top">using&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespace_t_o_k_e_n___n_a_m_e.html#a90f15481940a6f47f7f86fe0ab21bda4">TOKEN_NAME::Accounts</a> = <a class="el" href="struct_table.html">Table</a>&lt; <a class="el" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(currency), <a class="el" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(currency), <a class="el" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(account), <a class="el" href="struct_account.html">Account</a>, <a class="el" href="types_8h.html#aaa5d1cd013383c889537491c3cfd9aad">uint64_t</a> &gt;</td></tr>
<tr class="separator:a90f15481940a6f47f7f86fe0ab21bda4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1f84ac76d1761828020f97744b382d3d"><td class="memItemLeft" align="right" valign="top">typedef <a class="el" href="structeos_1_1token.html">eos::token</a>&lt; <a class="el" href="types_8h.html#aaa5d1cd013383c889537491c3cfd9aad">uint64_t</a>, <a class="el" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(currency)&gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespace_t_o_k_e_n___n_a_m_e.html#a1f84ac76d1761828020f97744b382d3d">TOKEN_NAME::CurrencyTokens</a></td></tr>
<tr class="separator:a1f84ac76d1761828020f97744b382d3d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7d3c8dd83df1817c27e7a732110b964d"><td class="memItemLeft" align="right" valign="top">using&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespace_t_o_k_e_n___n_a_m_e.html#a7d3c8dd83df1817c27e7a732110b964d">TOKEN_NAME::Accounts</a> = <a class="el" href="struct_table.html">Table</a>&lt; <a class="el" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(currency), <a class="el" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(currency), <a class="el" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(account), <a class="el" href="struct_account.html">Account</a>, <a class="el" href="types_8h.html#aaa5d1cd013383c889537491c3cfd9aad">uint64_t</a> &gt;</td></tr>
<tr class="separator:a7d3c8dd83df1817c27e7a732110b964d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
Expand Down
6 changes: 3 additions & 3 deletions docs/currency_8hpp_source.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/dir_a9257b511e702fbd3462fee4a063915c.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:currency_8hpp"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="currency_8hpp.html">currency.hpp</a> <a href="currency_8hpp_source.html">[code]</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:currency_8wast_8hpp"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="currency_8wast_8hpp.html">currency.wast.hpp</a> <a href="currency_8wast_8hpp_source.html">[code]</a></td></tr>
<tr class="memitem:currency_2currency_8wast_8hpp"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="currency_2currency_8wast_8hpp.html">currency.wast.hpp</a> <a href="currency_2currency_8wast_8hpp_source.html">[code]</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
</div><!-- contents -->
Expand Down
2 changes: 2 additions & 0 deletions docs/dir_ae9b15dd87e066e1908bbd90e8f38627.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:dir_44e8454330c52effb0ef98d8f3108add"><td class="memItemLeft" align="right" valign="top">directory &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="dir_44e8454330c52effb0ef98d8f3108add.html">social</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:dir_eeb4a3ec8dac95e5edcbc3ddc954d9f0"><td class="memItemLeft" align="right" valign="top">directory &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="dir_eeb4a3ec8dac95e5edcbc3ddc954d9f0.html">system</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
</div><!-- contents -->
<!-- start footer part -->
Expand Down
Loading

0 comments on commit a97251d

Please sign in to comment.