Skip to content

Commit

Permalink
chore(docs): Add tutorial for building channel-based applications (#695)
Browse files Browse the repository at this point in the history
* app-channel tutorial initial commit

* docs: config load clarification

* consensus message diagram

* color fix in diagram

* Update tutorial

* Add back use of proper tokio runtime in example app

* Finish up

* Add missing highlight

* Update TOC

* Add missing dep

* Add missing highlight

* Add missing highlight

* Break down handling of consensus messages

* Document how to handle each consensus message

* typo: modules names

* Describe the state and its methods

* Specify where to create the modules

* Add note about lag when starting nodes one by one

* Add spawn.bash script to example app

* Mention spawn.bash script in tutorial

* Add README to example app

---------

Co-authored-by: Romain Ruetschi <[email protected]>
Co-authored-by: Bastien Faivre <[email protected]>
  • Loading branch information
3 people authored Dec 18, 2024
1 parent 156218d commit 3bc850d
Show file tree
Hide file tree
Showing 9 changed files with 1,685 additions and 139 deletions.
81 changes: 40 additions & 41 deletions code/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion code/examples/channel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ bytes.workspace = true
color-eyre.workspace = true
derive-where.workspace = true
eyre.workspace = true
libp2p-identity.workspace = true
rand.workspace = true
serde_json.workspace = true
sha3.workspace = true
Expand Down
38 changes: 38 additions & 0 deletions code/examples/channel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Example channel-based app

This is an example application using the high-level channel-based interface for interacting with consensus.

For more background on this application, [please read the corresponding tutorial](/docs/tutorials/channels.md) which goes over everything needed to write such an application.

## Run a local testnet

### Compile the app

```
$ cargo build
```

### Setup the testnet

Generate configuration and genesis for three nodes using the `testnet` command:

```
$ cargo run -- testnet --nodes 3 --home nodes
```

This will create the configuration for three nodes in the `nodes` folder. Feel free to inspect this folder and look at the generated files.

### Spawn the nodes

```
$ bash spawn.bash --nodes 3 --home nodes
```

If successful, the logs for each node can then be found at `nodes/X/logs/node.log`.

```
$ tail -f nodes/0/logs/node.log
```

Press `Ctrl-C` to stop all the nodes.

Loading

0 comments on commit 3bc850d

Please sign in to comment.