Skip to content

Commit

Permalink
Add duplicate position open check for transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
cronokirby committed Feb 29, 2024
1 parent 789ff2a commit 5934eee
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ impl ActionHandler for PositionOpen {
Ok(())
}

async fn check_stateful<S: StateRead + 'static>(&self, state: Arc<S>) -> Result<()> {
// Validate that the position ID doesn't collide
state.check_position_id_unused(&self.position.id()).await?;

async fn check_stateful<S: StateRead + 'static>(&self, _state: Arc<S>) -> Result<()> {
Ok(())
}

async fn execute<S: StateWrite>(&self, mut state: S) -> Result<()> {
// Validate that the position ID doesn't collide
state.check_position_id_unused(&self.position.id()).await?;
state.put_position(self.position.clone()).await?;
state.record_proto(event::position_open(self));
Ok(())
Expand Down

0 comments on commit 5934eee

Please sign in to comment.