@@ -6,49 +6,29 @@ use rollup_node_watcher::L1Notification;
66use scroll_db:: { Database , DatabaseOperations } ;
77use std:: {
88 collections:: VecDeque ,
9- fmt,
10- future:: Future ,
119 pin:: Pin ,
1210 sync:: Arc ,
1311 task:: { Context , Poll } ,
1412} ;
1513
14+ mod action;
15+ use action:: IndexerAction ;
16+
1617mod event;
1718pub use event:: IndexerEvent ;
1819
1920mod error;
2021use error:: IndexerError ;
2122
22- /// A future that resolves to a tuple of the block info and the block import outcome.
23- type PendingIndexerFuture =
24- Pin < Box < dyn Future < Output = Result < IndexerEvent , IndexerError > > + Send > > ;
25-
26- enum IndexerAction {
27- HandleReorg ( PendingIndexerFuture ) ,
28- HandleBatchCommit ( PendingIndexerFuture ) ,
29- HandleBatchFinalization ( PendingIndexerFuture ) ,
30- HandleL1Message ( PendingIndexerFuture ) ,
31- }
32-
3323/// The indexer is responsible for indexing data relevant to the L1.
24+ #[ derive( Debug ) ]
3425pub struct Indexer {
3526 /// A reference to the database used to persist the indexed data.
3627 database : Arc < Database > ,
3728 /// A queue of pending futures.
3829 pending_futures : VecDeque < IndexerAction > ,
3930}
4031
41- impl IndexerAction {
42- fn poll ( & mut self , cx : & mut Context < ' _ > ) -> Poll < Result < IndexerEvent , IndexerError > > {
43- match self {
44- Self :: HandleReorg ( fut) |
45- Self :: HandleBatchCommit ( fut) |
46- Self :: HandleBatchFinalization ( fut) |
47- Self :: HandleL1Message ( fut) => fut. as_mut ( ) . poll ( cx) ,
48- }
49- }
50- }
51-
5232impl Indexer {
5333 /// Creates a new indexer with the given [`Database`].
5434 pub fn new ( database : Arc < Database > ) -> Self {
@@ -149,16 +129,6 @@ impl Stream for Indexer {
149129 }
150130}
151131
152- impl fmt:: Debug for Indexer {
153- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
154- f. debug_struct ( "Indexer" )
155- . field ( "database" , & "Arc<Database>" ) // Hide actual DB details
156- . field ( "cmd_rx" , & "mpsc::UnboundedReceiver<IndexerCommand>" ) // Hide channel details
157- . field ( "pending_futures_len" , & self . pending_futures . len ( ) ) // Only print the queue length
158- . finish ( )
159- }
160- }
161-
162132#[ cfg( test) ]
163133mod test {
164134 use super :: * ;
0 commit comments