@@ -10,10 +10,10 @@ use sea_orm::{ActiveModelTrait, ColumnTrait, DbErr, EntityTrait, QueryFilter, Se
1010#[ async_trait:: async_trait]
1111pub trait DatabaseOperations : DatabaseConnectionProvider {
1212 /// Insert a [`BatchCommitData`] into the database.
13- async fn insert_batch ( & self , batch_input : BatchCommitData ) -> Result < ( ) , DatabaseError > {
14- tracing:: trace!( target: "scroll::db" , batch_hash = ?batch_input . hash, batch_index = batch_input . index, "Inserting batch input into database." ) ;
15- let batch_input : models:: batch_input :: ActiveModel = batch_input . into ( ) ;
16- batch_input . insert ( self . get_connection ( ) ) . await ?;
13+ async fn insert_batch ( & self , batch_commit : BatchCommitData ) -> Result < ( ) , DatabaseError > {
14+ tracing:: trace!( target: "scroll::db" , batch_hash = ?batch_commit . hash, batch_index = batch_commit . index, "Inserting batch input into database." ) ;
15+ let batch_commit : models:: batch_commit :: ActiveModel = batch_commit . into ( ) ;
16+ batch_commit . insert ( self . get_connection ( ) ) . await ?;
1717 Ok ( ( ) )
1818 }
1919
@@ -27,13 +27,13 @@ pub trait DatabaseOperations: DatabaseConnectionProvider {
2727 batch_hash : B256 ,
2828 block_number : u64 ,
2929 ) -> Result < ( ) , DatabaseError > {
30- if let Some ( batch) = models:: batch_input :: Entity :: find ( )
31- . filter ( models:: batch_input :: Column :: Hash . eq ( batch_hash. to_vec ( ) ) )
30+ if let Some ( batch) = models:: batch_commit :: Entity :: find ( )
31+ . filter ( models:: batch_commit :: Column :: Hash . eq ( batch_hash. to_vec ( ) ) )
3232 . one ( self . get_connection ( ) )
3333 . await ?
3434 {
3535 tracing:: trace!( target: "scroll::db" , batch_hash = ?batch_hash, block_number, "Finalizing batch input in database." ) ;
36- let mut batch: models:: batch_input :: ActiveModel = batch. into ( ) ;
36+ let mut batch: models:: batch_commit :: ActiveModel = batch. into ( ) ;
3737 batch. finalized_block_number = Set ( Some ( block_number as i64 ) ) ;
3838 batch. update ( self . get_connection ( ) ) . await ?;
3939 } else {
@@ -54,7 +54,7 @@ pub trait DatabaseOperations: DatabaseConnectionProvider {
5454 & self ,
5555 batch_index : u64 ,
5656 ) -> Result < Option < BatchCommitData > , DatabaseError > {
57- Ok ( models:: batch_input :: Entity :: find_by_id (
57+ Ok ( models:: batch_commit :: Entity :: find_by_id (
5858 TryInto :: < i64 > :: try_into ( batch_index) . expect ( "index should fit in i64" ) ,
5959 )
6060 . one ( self . get_connection ( ) )
@@ -65,8 +65,8 @@ pub trait DatabaseOperations: DatabaseConnectionProvider {
6565 /// Delete all [`BatchCommitData`]s with a block number greater than the provided block number.
6666 async fn delete_batches_gt ( & self , block_number : u64 ) -> Result < ( ) , DatabaseError > {
6767 tracing:: trace!( target: "scroll::db" , block_number, "Deleting batch inputs greater than block number." ) ;
68- Ok ( models:: batch_input :: Entity :: delete_many ( )
69- . filter ( models:: batch_input :: Column :: BlockNumber . gt ( block_number as i64 ) )
68+ Ok ( models:: batch_commit :: Entity :: delete_many ( )
69+ . filter ( models:: batch_commit :: Column :: BlockNumber . gt ( block_number as i64 ) )
7070 . exec ( self . get_connection ( ) )
7171 . await
7272 . map ( |_| ( ) ) ?)
@@ -76,7 +76,7 @@ pub trait DatabaseOperations: DatabaseConnectionProvider {
7676 async fn get_batches < ' a > (
7777 & ' a self ,
7878 ) -> Result < impl Stream < Item = Result < BatchCommitData , DbErr > > + ' a , DbErr > {
79- Ok ( models:: batch_input :: Entity :: find ( )
79+ Ok ( models:: batch_commit :: Entity :: find ( )
8080 . stream ( self . get_connection ( ) )
8181 . await ?
8282 . map ( |res| res. map ( Into :: into) ) )
0 commit comments