Skip to content

Commit

Permalink
No prelude
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Sep 9, 2023
1 parent b8b90af commit 20d1f86
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 25 deletions.
10 changes: 2 additions & 8 deletions crates/fault/src/clock.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
16 changes: 11 additions & 5 deletions crates/fault/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*};
}
2 changes: 1 addition & 1 deletion crates/fault/src/position.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion crates/fault/src/providers.rs
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion crates/fault/src/response.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion crates/fault/src/solver.rs
Original file line number Diff line number Diff line change
@@ -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
9 changes: 4 additions & 5 deletions crates/fault/src/state.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down
17 changes: 14 additions & 3 deletions crates/fault/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ClaimData>;
Expand Down Expand Up @@ -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;
}

0 comments on commit 20d1f86

Please sign in to comment.