Skip to content

Commit

Permalink
including all finalize info in the language guide, remove finalize fi…
Browse files Browse the repository at this point in the history
…le, update overview links
  • Loading branch information
kpandl committed Oct 4, 2023
1 parent d5a0209 commit 3dcf2ae
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 59 deletions.
1 change: 0 additions & 1 deletion documentation/00_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ An index of all pages available in this documentation.
- [Leo Code Editor Plugins](./leo/06_tooling.md)
- [Leo Examples, Guides, and Developer Resources](./leo/07_resources.md)
- [Leo Cheatsheet](./leo/09_cheatsheet.md)
- [Finalize](./leo/10_finalize.md)

### Chapter 2: Leo by Example

Expand Down
9 changes: 5 additions & 4 deletions documentation/leo/03_language.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,17 +365,16 @@ The rules for functions (in the traditional sense) are as follows:

### Finalize Function

A finalize function is declared as `finalize {name}:`.
A finalize function must immediately follow a [transition function](#transition-function), and must have the same name;
A finalize function is declared as `finalize {name}:` and is used to run computations on chain. One of its primary purposes is to initiate or change public on chain state within mappings. A finalize function must immediately follow a transition function, and must have the same name;
it is associated with the transition function and is executed on chain,
after the zero-knowledge proof of the execution of the associated transition is verified;
a finalize function _finalizes_ a transition function on chain.
Upon success of the finalize function, the program logic is executed.
Upon failure of the finalize function, the program logic is reverted.

More information on finalize functions can be found [here](./10_finalize.md).
Consequently, nodes on the Aleo network execute the code of the finalize function. Only code within finalize blocks, run by nodes on the Aleo Network, updates program mappings. Only a program can write into its own mapping, but all nodes on the Aleo network can read the public state.

```leo showLineNumbers
An example of on-chain state mutation is the transfer_public_to_private transition in the finalize example, which updates the public account mapping (and thus a user's balance) when called.

```leo showLineNumbers
program transfer.aleo {
Expand Down Expand Up @@ -411,6 +410,8 @@ program transfer.aleo {
}
```

If there is no need to create or alter the public on-chain state, finalize functions are not required.

### Mapping

A mapping is declared as `mapping {name}: {key-type} => {value-type}`.
Expand Down
54 changes: 0 additions & 54 deletions documentation/leo/10_finalize.md

This file was deleted.

0 comments on commit 3dcf2ae

Please sign in to comment.