diff --git a/crates/fault/src/clock.rs b/crates/fault/src/clock.rs index 5cd2f11..96411c0 100644 --- a/crates/fault/src/clock.rs +++ b/crates/fault/src/clock.rs @@ -1,14 +1,8 @@ //! The position module holds the [Clock] type. -pub type Clock = u128; - -pub trait ChessClock { - /// Returns the seconds elapsed on the chess clock in seconds. - fn duration(&self) -> u64; +use crate::ChessClock; - /// Returns the timestamp of when the chess clock was last stopped. - fn timestamp(&self) -> u64; -} +pub type Clock = u128; impl ChessClock for Clock { fn duration(&self) -> u64 { diff --git a/crates/fault/src/lib.rs b/crates/fault/src/lib.rs index 6107296..7f705be 100644 --- a/crates/fault/src/lib.rs +++ b/crates/fault/src/lib.rs @@ -3,15 +3,21 @@ extern crate durin_primitives; mod clock; +pub use clock::Clock; + mod position; +pub use position::{compute_gindex, Position}; + mod providers; + mod response; -mod solver; +pub use response::FaultSolverResponse; + mod state; +pub use state::{ClaimData, FaultDisputeState}; + mod traits; +pub use traits::*; +mod solver; pub use solver::*; - -pub mod prelude { - pub use super::{clock::*, position::*, providers::*, response::*, traits::*}; -} diff --git a/crates/fault/src/position.rs b/crates/fault/src/position.rs index 8b83ccb..5be1167 100644 --- a/crates/fault/src/position.rs +++ b/crates/fault/src/position.rs @@ -1,7 +1,7 @@ //! The position module holds the [Position] type and the implementation of the [Gindex] //! trait on it. -use crate::prelude::Gindex; +use crate::Gindex; pub type Position = u128; diff --git a/crates/fault/src/providers.rs b/crates/fault/src/providers.rs index ac0efca..24af8a4 100644 --- a/crates/fault/src/providers.rs +++ b/crates/fault/src/providers.rs @@ -1,3 +1,3 @@ -//! This modules contains trace providers for the variants of the [crate::prelude::FaultDisputeGame]. +//! This modules contains trace providers for the variants of the [crate::FaultDisputeGame]. //! //! TODO diff --git a/crates/fault/src/response.rs b/crates/fault/src/response.rs index f5337b7..566f5f8 100644 --- a/crates/fault/src/response.rs +++ b/crates/fault/src/response.rs @@ -1,4 +1,4 @@ -//! Holds the response type for a [crate::prelude::FaultDisputeGame] +//! Holds the response type for a [crate::FaultDisputeGame] /// The [FaultSolverResponse] enum describes the response that a solver should /// return when asked to make a move. diff --git a/crates/fault/src/solver.rs b/crates/fault/src/solver.rs index 2097f4e..81ac41e 100644 --- a/crates/fault/src/solver.rs +++ b/crates/fault/src/solver.rs @@ -1,3 +1,3 @@ -//! This module contains the various implementations of the [crate::prelude::FaultDisputeSolver] trait. +//! This module contains the various implementations of the [crate::FaultDisputeSolver] trait. //! //! TODO diff --git a/crates/fault/src/state.rs b/crates/fault/src/state.rs index 0a6b3c7..9ff232a 100644 --- a/crates/fault/src/state.rs +++ b/crates/fault/src/state.rs @@ -1,13 +1,12 @@ -//! This module contains the in-memory represtentation of a -//! [crate::prelude::FaultDisputeGame]'s state +//! This module contains the in-memory represtentation of a [crate::FaultDisputeGame]'s state #![allow(dead_code, unused_variables)] -use crate::prelude::{Clock, FaultDisputeGame, Position}; +use crate::{Clock, FaultDisputeGame, Position}; use durin_primitives::{Claim, DisputeGame, GameStatus}; /// The [ClaimData] struct holds the data associated with a claim within a -/// [crate::prelude::FaultDisputeGame]'s state on-chain. +/// [crate::FaultDisputeGame]'s state on-chain. pub struct ClaimData { parent_index: u32, countered: bool, @@ -17,7 +16,7 @@ pub struct ClaimData { } /// the [FaultDisputeState] struct holds the in-memory representation of a -/// [crate::prelude::FaultDisputeGame]'s state as well as its root claim and +/// [crate::FaultDisputeGame]'s state as well as its root claim and /// local status. pub struct FaultDisputeState { /// The [FaultDisputeState] is modeled as a directed acyclical graph (DAG) of diff --git a/crates/fault/src/traits.rs b/crates/fault/src/traits.rs index 15f8d90..688e7dd 100644 --- a/crates/fault/src/traits.rs +++ b/crates/fault/src/traits.rs @@ -2,14 +2,14 @@ use crate::{ position::Position, - prelude::FaultSolverResponse, state::{ClaimData, FaultDisputeState}, + FaultSolverResponse, }; use durin_primitives::{Claim, DisputeGame, DisputeSolver}; -/// A [FaultDisputeGame] is a [DisputeGame] that is played over a [FaultVM] backend. This +/// A [FaultDisputeGame] is a [DisputeGame] that is played over a FaultVM backend. This /// trait extends the [DisputeGame] trait with functionality that is specific to the -/// fault [crate::dispute_game::GameType] variants. +/// fault [durin_primitives::GameType] variants. pub trait FaultDisputeGame: DisputeGame { /// Returns a shared reference to the raw state of the game DAG. fn state(&self) -> &Vec; @@ -70,3 +70,14 @@ pub trait Gindex { /// Returns the relative [Position] for an attack or defense move against the current [Position]. fn make_move(&self, is_attack: bool) -> Self; } + +/// The [ChessClock] trait defines the interface of a single side of a chess clock +/// at a given state in time. +pub trait ChessClock { + /// Returns the seconds elapsed on the chess clock in seconds when it was + /// last stopped. + fn duration(&self) -> u64; + + /// Returns the timestamp of when the chess clock was last stopped. + fn timestamp(&self) -> u64; +} diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 952aac0..51eea0f 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -9,6 +9,3 @@ pub use dispute_game::{Claim, GameStatus, GameType}; mod traits; pub use traits::{DisputeGame, DisputeSolver}; - -// Re-export alloy primitives -pub use alloy_primitives::*;