@@ -8,12 +8,13 @@ export class AccountSynchronizer extends Synchronizer<IAccount> {
88 private accountCollection ?: Collection < IAccount > ;
99 private contractAccounts : string [ ] = [ ] ;
1010 private tokenContracts : string [ ] = [ ] ;
11- private totalScopes : number = 0 ;
12- private processedScopes : number = 0 ;
13- private totalScopesToProcess : number = 0 ;
11+ private completedContracts : number = 0 ;
12+ private totalContracts : number = 0 ;
1413 private currentContractIndex : number = 0 ;
1514 private currentContract : string = '' ;
1615 private currentScope : string = '' ;
16+ private currentContractScopes : number = 0 ; // holder scopes processed in the current contract
17+ private totalScopesProcessed : number = 0 ; // holder scopes processed across all contracts
1718 private contractFilter ?: string ;
1819
1920 constructor ( chain : string , contractFilter ?: string ) {
@@ -109,6 +110,8 @@ export class AccountSynchronizer extends Synchronizer<IAccount> {
109110 const contract = this . tokenContracts [ i ] ;
110111 this . currentContract = contract ;
111112 this . currentContractIndex = i ;
113+ this . currentContractScopes = 0 ;
114+ this . currentScope = '' ;
112115 console . log ( `[DEBUG] Starting contract ${ i + 1 } /${ this . tokenContracts . length } : ${ contract } ` ) ;
113116
114117 let lowerBound : string = '' ;
@@ -143,12 +146,14 @@ export class AccountSynchronizer extends Synchronizer<IAccount> {
143146 } catch ( e : any ) {
144147 console . log ( `Failed to check balance ${ row . scope } @${ contract } - ${ e . message } ` ) ;
145148 }
149+ this . currentContractScopes ++ ;
150+ this . totalScopesProcessed ++ ;
146151 }
147152 lowerBound = scopes . more ;
148153 } while ( lowerBound !== '' ) ;
149-
154+
150155 // Mark this contract as processed
151- this . processedScopes = i + 1 ;
156+ this . completedContracts = i + 1 ;
152157 console . log ( `[DEBUG] Completed contract ${ i + 1 } /${ this . tokenContracts . length } : ${ contract } ` ) ;
153158 }
154159 console . log ( `[DEBUG] All contracts processed` ) ;
@@ -169,7 +174,7 @@ export class AccountSynchronizer extends Synchronizer<IAccount> {
169174
170175 await this . scanABIs ( ) ;
171176 console . log ( `Number of validated token contracts: ${ this . tokenContracts . length } ` ) ;
172- this . totalScopesToProcess = this . tokenContracts . length ;
177+ this . totalContracts = this . tokenContracts . length ;
173178
174179 await this . setupMongo ( ) ;
175180
@@ -184,17 +189,24 @@ export class AccountSynchronizer extends Synchronizer<IAccount> {
184189 }
185190 return ;
186191 }
187- const progressPercent = this . totalScopesToProcess > 0 ? ( ( this . processedScopes / this . totalScopesToProcess ) * 100 ) . toFixed ( 2 ) : '0.00' ;
188-
189- let statusMessage = '' ;
190- if ( this . processedScopes >= this . totalScopesToProcess ) {
192+ // Percentage is driven by completed contracts (the only total known up front).
193+ // The holder/balance counters below move continuously so a long single-contract
194+ // sync no longer looks stuck at 0%.
195+ const progressPercent = this . totalContracts > 0 ? ( ( this . completedContracts / this . totalContracts ) * 100 ) . toFixed ( 1 ) : '0.0' ;
196+
197+ let statusMessage : string ;
198+ if ( this . totalContracts > 0 && this . completedContracts >= this . totalContracts ) {
191199 statusMessage = 'finalizing database writes...' ;
200+ } else if ( this . currentContract ) {
201+ // currentContractIndex is 0-based and set when a contract starts, so +1 reflects the contract in progress
202+ const contractPos = Math . min ( this . currentContractIndex + 1 , this . totalContracts ) ;
203+ statusMessage = `contract ${ contractPos } /${ this . totalContracts } ${ this . currentContract } (${ this . currentContractScopes } holders) - current: ${ this . currentScope || '...' } ` ;
192204 } else {
193- statusMessage = this . currentContract ? ` ${ this . currentScope } @ ${ this . currentContract } ` : 'initializing...' ;
205+ statusMessage = 'initializing...' ;
194206 }
195-
207+
196208 const timestamp = new Date ( ) . toISOString ( ) . split ( 'T' ) [ 1 ] . split ( '.' ) [ 0 ] ; // HH:MM:SS format
197- console . log ( `[${ timestamp } ] Progress: ${ this . processedScopes } / ${ this . totalScopesToProcess } ( ${ progressPercent } %) - ${ statusMessage } - ${ this . totalItems } accounts ` ) ;
209+ console . log ( `[${ timestamp } ] ${ progressPercent } % | holders scanned: ${ this . totalScopesProcessed } | balances: ${ this . totalItems } | ${ statusMessage } ` ) ;
198210 } , 1000 ) ;
199211
200212 try {
0 commit comments