Increment Count
Add an increment
function that increments the counter's value by one. The function reads the current count, increments it, and then creates a new solution with the updated count. The solution is then submitted to the builder to be included in a block.
#![allow(unused)] fn main() { async fn increment(dbs: &utils::db::Dbs) { let current_count = extract_count( utils::node::query_state_head(&dbs.node, &ADDRESS, &counter_key().0) .await .unwrap(), ) .unwrap(); utils::builder::submit(&dbs.builder, create_solution(current_count + 1)) .await .unwrap(); } }
Here, we're calling the increment
function to increase the counter's value. This function interacts with the builder to update the counter's state.
#![allow(unused)] fn main() { #[tokio::test] async fn test() { // ... increment(&dbs).await; } }