@@ -23,6 +23,13 @@ use error::IndexerError;
2323type PendingIndexerFuture =
2424 Pin < Box < dyn Future < Output = Result < IndexerEvent , IndexerError > > + Send > > ;
2525
26+ enum IndexerAction {
27+ HandleReorg ( PendingIndexerFuture ) ,
28+ HandleBatchCommit ( PendingIndexerFuture ) ,
29+ HandleBatchFinalization ( PendingIndexerFuture ) ,
30+ HandleL1Message ( PendingIndexerFuture ) ,
31+ }
32+
2633/// The indexer is responsible for indexing data relevant to the L1.
2734pub struct Indexer {
2835 /// A reference to the database used to persist the indexed data.
@@ -31,20 +38,13 @@ pub struct Indexer {
3138 pending_futures : VecDeque < IndexerAction > ,
3239}
3340
34- enum IndexerAction {
35- HandleReorg ( PendingIndexerFuture ) ,
36- HandleBatchCommit ( PendingIndexerFuture ) ,
37- HandleBatchFinalization ( PendingIndexerFuture ) ,
38- HandleL1Message ( PendingIndexerFuture ) ,
39- }
40-
4141impl IndexerAction {
4242 fn poll ( & mut self , cx : & mut Context < ' _ > ) -> Poll < Result < IndexerEvent , IndexerError > > {
4343 match self {
44- IndexerAction :: HandleReorg ( fut) => fut . as_mut ( ) . poll ( cx ) ,
45- IndexerAction :: HandleBatchCommit ( fut) => fut . as_mut ( ) . poll ( cx ) ,
46- IndexerAction :: HandleBatchFinalization ( fut) => fut . as_mut ( ) . poll ( cx ) ,
47- IndexerAction :: HandleL1Message ( fut) => fut. as_mut ( ) . poll ( cx) ,
44+ Self :: HandleReorg ( fut) |
45+ Self :: HandleBatchCommit ( fut) |
46+ Self :: HandleBatchFinalization ( fut) |
47+ Self :: HandleL1Message ( fut) => fut. as_mut ( ) . poll ( cx) ,
4848 }
4949 }
5050}
@@ -104,7 +104,7 @@ impl Indexer {
104104 l1_message : L1MessageWithBlockNumber ,
105105 ) -> Result < IndexerEvent , IndexerError > {
106106 let event = IndexerEvent :: L1MessageIndexed ( l1_message. transaction . queue_index ) ;
107- let _ = database. insert_l1_message ( l1_message) . await ?;
107+ database. insert_l1_message ( l1_message) . await ?;
108108 Ok ( event)
109109 }
110110
@@ -114,7 +114,7 @@ impl Indexer {
114114 batch_input : BatchInput ,
115115 ) -> Result < IndexerEvent , IndexerError > {
116116 let event = IndexerEvent :: BatchCommitIndexed ( batch_input. batch_index ( ) ) ;
117- let _ = database. insert_batch_input ( batch_input) . await ?;
117+ database. insert_batch_input ( batch_input) . await ?;
118118 Ok ( event)
119119 }
120120
@@ -125,7 +125,7 @@ impl Indexer {
125125 block_number : u64 ,
126126 ) -> Result < IndexerEvent , IndexerError > {
127127 let event = IndexerEvent :: BatchFinalizationIndexed ( block_number) ;
128- let _ = database. finalize_batch_input ( batch_hash, block_number) . await ?;
128+ database. finalize_batch_input ( batch_hash, block_number) . await ?;
129129 Ok ( event)
130130 }
131131}
@@ -135,7 +135,7 @@ impl Stream for Indexer {
135135
136136 fn poll_next ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Option < Self :: Item > > {
137137 // Remove and poll the next future in the queue
138- while let Some ( mut action) = self . pending_futures . pop_front ( ) {
138+ if let Some ( mut action) = self . pending_futures . pop_front ( ) {
139139 match action. poll ( cx) {
140140 Poll :: Ready ( result) => return Poll :: Ready ( Some ( result) ) ,
141141 Poll :: Pending => {
@@ -148,6 +148,7 @@ impl Stream for Indexer {
148148 Poll :: Pending
149149 }
150150}
151+
151152impl fmt:: Debug for Indexer {
152153 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
153154 f. debug_struct ( "Indexer" )
0 commit comments