@@ -205,6 +205,7 @@ export class HourlyClosureWatcher {
205205
206206 let closuresFound = 0 ;
207207 let disputesSubmitted = 0 ;
208+ let skippedAlreadyDisputed = 0 ;
208209 let pipesScanned = 0 ;
209210 for ( const trackedPipe of trackedPipes ) {
210211 pipesScanned += 1 ;
@@ -231,7 +232,13 @@ export class HourlyClosureWatcher {
231232 }
232233
233234 closuresFound += 1 ;
235+ const existingClosure = this . agentService . stateStore . getClosure ( closure . txid ) ;
234236 this . agentService . stateStore . recordClosure ( closure ) ;
237+ if ( existingClosure ?. disputed ) {
238+ skippedAlreadyDisputed += 1 ;
239+ continue ;
240+ }
241+
235242 const disputeResult = await this . agentService . disputeClosure ( {
236243 closureEvent : closure ,
237244 walletPassword : this . walletPassword ,
@@ -247,6 +254,7 @@ export class HourlyClosureWatcher {
247254 pipesScanned,
248255 closuresFound,
249256 disputesSubmitted,
257+ skippedAlreadyDisputed,
250258 } ;
251259 } finally {
252260 this . running = false ;
@@ -280,6 +288,7 @@ export class HourlyClosureWatcher {
280288
281289 let highestBlock = parseUnsignedBigInt ( fromBlockHeight , "fromBlockHeight" ) ;
282290 let disputesSubmitted = 0 ;
291+ let skippedAlreadyDisputed = 0 ;
283292 let scanned = 0 ;
284293
285294 for ( const rawEvent of events ) {
@@ -290,14 +299,18 @@ export class HourlyClosureWatcher {
290299 continue ;
291300 }
292301 scanned += 1 ;
302+ const existingClosure = this . agentService . stateStore . getClosure ( closure . txid ) ;
293303 this . agentService . stateStore . recordClosure ( closure ) ;
294-
295- const disputeResult = await this . agentService . disputeClosure ( {
296- closureEvent : closure ,
297- walletPassword : this . walletPassword ,
298- } ) ;
299- if ( disputeResult . submitted ) {
300- disputesSubmitted += 1 ;
304+ if ( existingClosure ?. disputed ) {
305+ skippedAlreadyDisputed += 1 ;
306+ } else {
307+ const disputeResult = await this . agentService . disputeClosure ( {
308+ closureEvent : closure ,
309+ walletPassword : this . walletPassword ,
310+ } ) ;
311+ if ( disputeResult . submitted ) {
312+ disputesSubmitted += 1 ;
313+ }
301314 }
302315
303316 const block = parseUnsignedBigInt ( closure . blockHeight , "blockHeight" ) ;
@@ -311,6 +324,7 @@ export class HourlyClosureWatcher {
311324 ok : true ,
312325 scanned,
313326 disputesSubmitted,
327+ skippedAlreadyDisputed,
314328 fromBlockHeight,
315329 toBlockHeight : highestBlock . toString ( 10 ) ,
316330 } ;
0 commit comments