Skip to content

Commit a278ed3

Browse files
committed
feat(orap): add disabled options for event crosscheck
1 parent 6536db7 commit a278ed3

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

packages/orap/src/flow/event.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Context } from '../task'
33
import type { TaskFlowParams } from '../flow/task'
44
import { TaskFlow } from '../flow/task'
55
import { StoreManager } from '../store'
6-
import type { EventSignalRegisterParams } from '../signal'
6+
import type { CrosscheckOptions, EventSignalRegisterParams } from '../signal'
77
import { EventVerse } from '../verse/event'
88
import type { TaskVerse } from '../verse/task'
99
import type { Flow, HandleFn } from './interface'
@@ -33,7 +33,7 @@ export class EventFlow implements Flow {
3333
return this._taskFlows
3434
}
3535

36-
crosscheck(options?: Omit<AutoCrossCheckParam, 'address' | 'topics' | 'onMissingLog'>) {
36+
crosscheck(options?: CrosscheckOptions) {
3737
this.partialCrosscheckOptions = options
3838
return this
3939
}

packages/orap/src/signal/event.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ export interface EventSignalRegisterParams {
1212
// esig?: string,
1313
}
1414

15+
export interface CrosscheckParams {
16+
/**
17+
* Disable crosscheck
18+
*/
19+
disabled?: boolean
20+
}
21+
22+
export type CrosscheckOptions = CrosscheckParams & Omit<AutoCrossCheckParam, 'address' | 'topics' | 'onMissingLog'>
23+
1524
export type EventSignalCallback = ethers.Listener
1625

1726
export class EventSignal implements Signal {
@@ -25,11 +34,12 @@ export class EventSignal implements Signal {
2534

2635
crosschecker?: AutoCrossChecker
2736
crosscheckerOptions?: AutoCrossCheckParam
37+
crosscheckerParams?: CrosscheckParams
2838

2939
constructor(
3040
public params: EventSignalRegisterParams,
3141
public callback: EventSignalCallback,
32-
crosscheckOptions?: Omit<AutoCrossCheckParam, 'address' | 'topics' | 'onMissingLog'>,
42+
crosscheckOptions?: CrosscheckOptions,
3343
) {
3444
this.contract = new ethers.Contract(
3545
params.address,
@@ -69,7 +79,7 @@ export class EventSignal implements Signal {
6979
return new ContractUnknownEventPayload(this.contract, this.subscribeCallback, this.params.eventName, log)
7080
}
7181

72-
private _setCrosscheckOptions(options: Omit<AutoCrossCheckParam, 'address' | 'topics' | 'onMissingLog'>) {
82+
private _setCrosscheckOptions(options: CrosscheckOptions) {
7383
const {
7484
pollingInterval = ONE_MINUTE_MS * 60,
7585
ignoreLogs = [],
@@ -83,6 +93,9 @@ export class EventSignal implements Signal {
8393
pollingInterval,
8494
ignoreLogs,
8595
}
96+
this.crosscheckerParams = {
97+
disabled: options?.disabled,
98+
}
8699
}
87100

88101
// TODO: should be wsProvider only?
@@ -114,6 +127,9 @@ export class EventSignal implements Signal {
114127
}
115128

116129
async startCrossChecker(provider?: Providers) {
130+
if (this.crosscheckerParams?.disabled)
131+
return
132+
117133
if (!this.crosscheckerOptions)
118134
return
119135
if (!provider)

0 commit comments

Comments
 (0)