@@ -234,6 +234,8 @@ export class HyperionMaster {
234234 tx : msg . trx_ids
235235 } ) ;
236236
237+ this . lastProducedBlockNum = msg . block_num ;
238+
237239 if ( this . conf . settings . bp_monitoring && ! this . conf . indexer . abi_scan_mode ) {
238240 this . liveBlockQueue . push ( msg ) . catch ( reason => {
239241 hLog ( 'Error handling consumed_block:' , reason ) ;
@@ -326,17 +328,38 @@ export class HyperionMaster {
326328 if ( end > this . head ) {
327329 end = this . head ;
328330 }
329- this . lastAssignedBlock += this . maxBatchSize ;
330331 const def = {
331332 first_block : start ,
332333 last_block : end
333334 } ;
335+ this . lastAssignedBlock = def . last_block ;
334336 this . activeReadersCount ++ ;
335337 messageAllWorkers ( cluster , {
336338 event : 'new_range' ,
337339 target : msg . id ,
338340 data : def
339341 } ) ;
342+ } else {
343+ if ( this . lastAssignedBlock >= this . head ) {
344+ hLog ( `Parallel readers finished the requested range` ) ;
345+ const readers = this . workerMap . filter ( value => value . worker_role === 'reader' ) ;
346+ this . workerMap = this . workerMap . filter ( value => value . worker_role !== 'reader' ) ;
347+ readers . forEach ( value => value . wref . kill ( ) ) ;
348+ // for (let hyperionWorkerDef of this.workerMap) {
349+ // if (hyperionWorkerDef.worker_role === 'reader') {
350+ // hyperionWorkerDef.wref.kill();
351+ // }
352+ // }
353+ // for (let workersKey in cluster.workers) {
354+ // const w = cluster.workers[workersKey];
355+ // console.log(w);
356+ // if (w.id === parseInt(msg.id)) {
357+ // const idx = this.workerMap.findIndex(value => value.worker_id === w.id);
358+ // this.workerMap.splice(idx, 1);
359+ // w.kill();
360+ // }
361+ // }
362+ }
340363 }
341364 }
342365 } ,
@@ -1461,6 +1484,12 @@ export class HyperionMaster {
14611484 avg_consume_rate = consume_rate ;
14621485 }
14631486 const log_msg = [ ] ;
1487+
1488+ // print current head for live reading
1489+ if ( this . lastProducedBlockNum > 0 ) {
1490+ log_msg . push ( `#${ this . lastProducedBlockNum } ` ) ;
1491+ }
1492+
14641493 log_msg . push ( `W:${ _workers } ` ) ;
14651494
14661495 const _r = ( this . pushedBlocks + this . livePushedBlocks ) / tScale ;
@@ -1484,9 +1513,12 @@ export class HyperionMaster {
14841513 this . metrics . indexingRate ?. set ( _ir ) ;
14851514
14861515 if ( this . total_blocks < this . total_range && ! this . conf . indexer . live_only_mode ) {
1487- const remaining = this . total_range - this . total_blocks ;
1488- const estimated_time = Math . round ( remaining / avg_consume_rate ) ;
1489- const time_string = moment ( ) . add ( estimated_time , 'seconds' ) . fromNow ( false ) ;
1516+ let time_string = 'waiting for indexer' ;
1517+ if ( avg_consume_rate > 0 ) {
1518+ const remaining = this . total_range - this . total_blocks ;
1519+ const estimated_time = Math . round ( remaining / avg_consume_rate ) ;
1520+ time_string = moment ( ) . add ( estimated_time , 'seconds' ) . fromNow ( false ) ;
1521+ }
14901522 const pct_parsed = ( ( this . total_blocks / this . total_range ) * 100 ) . toFixed ( 1 ) ;
14911523 const pct_read = ( ( this . total_read / this . total_range ) * 100 ) . toFixed ( 1 ) ;
14921524 log_msg . push ( `${ this . total_blocks } /${ this . total_read } /${ this . total_range } ` ) ;
@@ -1510,7 +1542,7 @@ export class HyperionMaster {
15101542 hLog ( log_msg . join ( ' | ' ) ) ;
15111543 }
15121544
1513- if ( this . liveConsumedBlocks > 0 && this . consumedBlocks === 0 && this . conf . indexer . abi_scan_mode ) {
1545+ if ( this . liveConsumedBlocks > 0 && this . consumedBlocks === 0 && this . conf . indexer . abi_scan_mode ) {
15141546 hLog ( 'Warning: Live reading on ABI SCAN mode' )
15151547 }
15161548
0 commit comments