some code cleanup
This commit is contained in:
parent
0bd6af6358
commit
603e8d9870
|
@ -4344,6 +4344,7 @@ dependencies = [
|
|||
"ctrlc",
|
||||
"eframe",
|
||||
"egui",
|
||||
"secp256k1 0.26.0",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
|
|
|
@ -1,18 +1,13 @@
|
|||
use eframe::egui;
|
||||
use secp256k1::SecretKey;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cell::OnceCell;
|
||||
use std::str::from_utf8;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
use std::str::FromStr;
|
||||
use std::time::SystemTime;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::{SystemTime, Duration};
|
||||
|
||||
use tokio::sync::mpsc;
|
||||
use waku::{
|
||||
waku_new, Encoding, Event, Initialized, LibwakuResponse, Multiaddr, Running, WakuContentTopic,
|
||||
WakuMessage, WakuNodeConfig, WakuNodeContext, WakuNodeHandle,
|
||||
waku_new, Encoding, Event, LibwakuResponse, WakuContentTopic,
|
||||
WakuMessage, WakuNodeConfig, WakuNodeHandle,
|
||||
};
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Copy, Clone)]
|
||||
|
@ -28,13 +23,6 @@ struct GameState {
|
|||
moves_left: usize,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct MoveMessage {
|
||||
row: usize,
|
||||
col: usize,
|
||||
player: Player,
|
||||
}
|
||||
|
||||
struct TicTacToeApp {
|
||||
game_state: Arc<Mutex<GameState>>,
|
||||
waku: WakuNodeHandle,
|
||||
|
@ -95,7 +83,7 @@ impl TicTacToeApp {
|
|||
};
|
||||
|
||||
// Establish a closure that handles the incoming messages
|
||||
self.waku.ctx.waku_set_event_callback(my_closure);
|
||||
self.waku.ctx.waku_set_event_callback(my_closure).expect("set event call back working");
|
||||
|
||||
// Subscribe to desired topic
|
||||
self.waku.relay_subscribe(&self.game_topic.to_string()).expect("waku should subscribe");
|
||||
|
@ -235,7 +223,6 @@ impl eframe::App for TicTacToeApp {
|
|||
ui.label(format!("You are playing as: {:?}", player_role));
|
||||
|
||||
// Draw the game board and handle the game state
|
||||
let text_size = 32.0;
|
||||
let board_size = ui.available_size();
|
||||
let cell_size = board_size.x / 4.0;
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ impl WakuNodeContext {
|
|||
/// which are used to react to asynchronous events in Waku
|
||||
pub fn waku_set_event_callback<F: FnMut(LibwakuResponse) + 'static + Sync + Send>(
|
||||
&self,
|
||||
mut closure: F,
|
||||
closure: F,
|
||||
) -> Result<(), String> {
|
||||
if let Ok(mut boxed_closure) = self.msg_observer.lock() {
|
||||
*boxed_closure = Box::new(closure);
|
||||
|
|
Loading…
Reference in New Issue