Skip to content

Commit

Permalink
Specify where to create the modules
Browse files Browse the repository at this point in the history
  • Loading branch information
romac committed Dec 18, 2024
1 parent 5282152 commit 905f832
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions docs/tutorials/channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,18 @@ package = "informalsystems-malachitebft-test-cli"
### Handle consensus messages

We now need a way to process messages sent to the application by consensus, and act on those accordingly.
Let's define a `run` function in a new `app` module, which will wait for messages from consensus
Let's define a `run` function in a new `app` module in `src/app.rs`, which will wait for messages from consensus
and handle those by updating its state and sending back the appropriate responses.

```rust
// src/main.rs

mod app;
```

```rust
// src/app.rs

use std::time::Duration;

use eyre::eyre;
Expand Down Expand Up @@ -719,9 +727,17 @@ The astute reader will have noticed that the code above invokes several methods
This type implements a minimal (in-memory) state maintaining knowledge of the height, round and data transmitted,
as well as the various proposals seen so far and the values that have been decided.

Let's define it in a new `state` module:
Let's define it in a new `state` module in `src/state.rs` and add the following line to `src/main.rs`:

```
// src/main.rs
mod state;
```

```rust
// src/state.rs

/// Represents the internal state of the application node
/// Contains information about current height, round, proposals and blocks
pub struct State {
Expand Down

0 comments on commit 905f832

Please sign in to comment.