File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ export class BlockMonitor {
1818 private txmgr : TransactionManager
1919 private unwatch : ( ( ) => void ) | undefined
2020 private blockTimeout : ReturnType < typeof setTimeout > | undefined
21+ private latestProcessedBlockNumber : bigint | undefined
2122 constructor ( _transactionManager : TransactionManager ) {
2223 this . txmgr = _transactionManager
2324 }
@@ -27,10 +28,6 @@ export class BlockMonitor {
2728 this . unwatch = this . txmgr . viemClient . watchBlocks ( {
2829 onBlock : this . onNewBlock . bind ( this ) ,
2930 ...( this . txmgr . transportProtocol === "http" ? { pollingInterval : this . txmgr . pollingInterval } : { } ) ,
30- onError : ( error ) => {
31- Logger . instance . error ( LogTag . TXM , "Error watching blocks" , error )
32- this . resetBlockSubscription ( )
33- } ,
3431 } )
3532 }
3633
@@ -40,6 +37,16 @@ export class BlockMonitor {
4037 return
4138 }
4239
40+ if ( this . latestProcessedBlockNumber && block . number <= this . latestProcessedBlockNumber ) {
41+ Logger . instance . warn (
42+ LogTag . TXM ,
43+ "Received block number less than or equal to latest processed block number. Skipping." ,
44+ )
45+ return
46+ }
47+
48+ this . latestProcessedBlockNumber = block . number
49+
4350 if ( this . blockTimeout ) clearTimeout ( this . blockTimeout )
4451 eventBus . emit ( Topics . NewBlock , block )
4552
You can’t perform that action at this time.
0 commit comments