@@ -5,7 +5,13 @@ import {
55 EosioReaderConfig ,
66} from '@blockmatic/eosio-ship-reader' ;
77import { takeWhile } from 'rxjs/operators' ;
8- import { EOSIO_CONFIG , getLogger , KAFKA_CONFIG , KAFKA_TOPIC_CONFIG } from '../common/config' ;
8+ import {
9+ EOSIO_CONFIG ,
10+ getLogger ,
11+ KAFKA_CONFIG ,
12+ KAFKA_TOPIC_CONFIG ,
13+ sync_message_block_interval ,
14+ } from '../common/config' ;
915import {
1016 ActionHandlerResult ,
1117 delta_whitelist ,
@@ -21,9 +27,6 @@ const logger = getLogger('ship-reader-wrapper');
2127const signal_traps = [ 'SIGTERM' , 'SIGINT' , 'SIGUSR2' ] ;
2228const error_types = [ 'unhandledRejection' , 'uncaughtException' ] ;
2329
24- //current finality is 3 minutes, with a new block every 0.5s -> 360 blocks
25- const num_blocks_to_finality = 3 * 60 * 2 ;
26-
2730export class ShipReaderWrapper {
2831 config : ShipReaderWrapperConfig = undefined ;
2932 forked : boolean = false ;
@@ -155,9 +158,9 @@ export class ShipReaderWrapper {
155158 logger . trace ( `Current block ${ this . current_block } ` ) ;
156159
157160 // since replaying blocks is much faster, check within greater block-span
158- let syncStateCheckInterval : number = 10 * num_blocks_to_finality ;
161+ let syncStateCheckInterval : number = 10 * sync_message_block_interval ;
159162 if ( logger . isLevelEnabled ( 'trace' ) || this . reader_in_sync ) {
160- syncStateCheckInterval = num_blocks_to_finality ;
163+ syncStateCheckInterval = sync_message_block_interval ;
161164 }
162165
163166 if ( block . block_num % syncStateCheckInterval === 0 ) {
@@ -219,7 +222,7 @@ export class ShipReaderWrapper {
219222 ) : Promise < void > {
220223 const head_block = Number ( await getHeadBlockNum ( ) ) ;
221224 const head_diff = head_block - current_block ;
222- this . reader_in_sync = head_diff - num_blocks_to_finality <= 0 ;
225+ this . reader_in_sync = head_diff - EOSIO_CONFIG . num_blocks_to_finality <= 0 ;
223226
224227 if ( this . reader_in_sync ) {
225228 logger . info ( 'Reader is in sync with current block height' ) ;
0 commit comments