Skip to content

Commit

Permalink
fix: remove unwraps in storage.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasti810 committed Jul 18, 2024
1 parent 6c3c22d commit 7be0f61
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 182 deletions.
4 changes: 4 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ pub enum DatabaseError {
DeleteError(String),
#[error(transparent)]
GeneralError(#[from] GeneralError),
#[error("connecting to database: {0}")]
ConnectionError(String),
#[error("initializing database: {0}")]
InitializationError(String),
}

// Result alias for [`DataAvailabilityError`]
Expand Down
10 changes: 3 additions & 7 deletions src/node_types/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,20 +199,16 @@ impl Sequencer {
Err(_) => 0,
};

self.db.set_epoch(&epoch).map_err(DeimosError::Database)?;
self.db
.reset_epoch_operation_counter()
.map_err(DeimosError::Database)?;
self.db.set_epoch(&epoch)?;
self.db.reset_epoch_operation_counter()?;

// add the commitment for the operations ran since the last epoch
let current_commitment = self
.create_tree()?
.get_commitment()
.map_err(DeimosError::MerkleTree)?;

self.db
.add_commitment(&epoch, &current_commitment)
.map_err(DeimosError::Database)?;
self.db.add_commitment(&epoch, &current_commitment)?;

let proofs = match epoch > 0 {
true => match self.db.get_proofs_in_epoch(&(epoch - 1)) {
Expand Down
Loading

0 comments on commit 7be0f61

Please sign in to comment.