From b264d31355540be7c2892651d9e5fcb28ada8e59 Mon Sep 17 00:00:00 2001 From: frisitano Date: Fri, 25 Apr 2025 01:26:43 +0700 Subject: [PATCH] chore: improve database interface --- crates/database/db/src/operations.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/database/db/src/operations.rs b/crates/database/db/src/operations.rs index c1f00c9..83415e4 100644 --- a/crates/database/db/src/operations.rs +++ b/crates/database/db/src/operations.rs @@ -7,8 +7,8 @@ use futures::{Stream, StreamExt}; use rollup_node_primitives::{BatchCommitData, BatchInfo, BlockInfo, L1MessageEnvelope}; use scroll_alloy_rpc_types_engine::BlockDataHint; use sea_orm::{ - ActiveModelTrait, ColumnTrait, Condition, DbErr, EntityTrait, QueryFilter, QueryOrder, - QuerySelect, Set, + ActiveModelTrait, ColumnTrait, Condition, EntityTrait, QueryFilter, QueryOrder, QuerySelect, + Set, }; /// The [`DatabaseOperations`] trait provides methods for interacting with the database. @@ -100,11 +100,12 @@ pub trait DatabaseOperations: DatabaseConnectionProvider { /// Get an iterator over all [`BatchCommitData`]s in the database. async fn get_batches<'a>( &'a self, - ) -> Result> + 'a, DbErr> { + ) -> Result> + 'a, DatabaseError> + { Ok(models::batch_commit::Entity::find() .stream(self.get_connection()) .await? - .map(|res| res.map(Into::into))) + .map(|res| Ok(res.map(Into::into)?))) } /// Insert an [`L1MessageEnvelope`] into the database. @@ -156,11 +157,12 @@ pub trait DatabaseOperations: DatabaseConnectionProvider { /// Gets an iterator over all [`L1MessageEnvelope`]s in the database. async fn get_l1_messages<'a>( &'a self, - ) -> Result> + 'a, DatabaseError> { + ) -> Result> + 'a, DatabaseError> + { Ok(models::l1_message::Entity::find() .stream(self.get_connection()) .await? - .map(|res| res.map(Into::into))) + .map(|res| Ok(res.map(Into::into)?))) } /// Get the extra data for the provided [`BlockId`].