Skip to content

Commit

Permalink
fix: experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarranzav committed Jul 28, 2023
1 parent f2882c5 commit 5a38a4f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/indexer-common/src/allocations/query-fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class AllocationReceiptCollector implements ReceiptCollector {
private voucherRedemptionBatchThreshold: BigNumber
private voucherRedemptionMaxBatchSize: number
private protocolNetwork: string
private stop: boolean

constructor({
logger,
Expand All @@ -98,6 +99,7 @@ export class AllocationReceiptCollector implements ReceiptCollector {
allocationExchange,
networkSpecification,
}: AllocationReceiptCollectorOptions) {
this.stop = false
this.logger = logger.child({ component: 'AllocationReceiptCollector' })
this.metrics = registerReceiptMetrics(metrics, networkSpecification.networkIdentifier)
this.transactionManager = transactionManager
Expand Down Expand Up @@ -231,6 +233,10 @@ export class AllocationReceiptCollector implements ReceiptCollector {
}
}

async stopCollectingReceipts(): Promise<void> {
this.stop = true
}

private startReceiptCollecting() {
this.receiptsToCollect = new DHeap<AllocationReceiptsBatch>(null, {
compare: (t1, t2) => t1.timeout - t2.timeout,
Expand Down Expand Up @@ -261,7 +267,11 @@ export class AllocationReceiptCollector implements ReceiptCollector {
}

private startVoucherProcessing() {
const self = this
timer(30_000).pipe(async () => {
if (self.stop) {
return
}
const pendingVouchers = await this.pendingVouchers() // Ordered by value

const logger = this.logger.child({})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ let managementModels: IndexerManagementModels
let metrics: Metrics
let queryFeeModels: QueryFeeModels
let sequelize: Sequelize
let network: Network

const setup = async () => {
logger = createLogger({
Expand All @@ -59,7 +60,7 @@ const setup = async () => {
[],
)

const network = await Network.create(
network = await Network.create(
logger,
testNetworkSpecification,
queryFeeModels,
Expand Down Expand Up @@ -95,6 +96,7 @@ const teardownEach = async () => {
}

const teardownAll = async () => {
await network.receiptCollector.stopCollectingReceipts()
await sequelize.drop({})
}

Expand Down

0 comments on commit 5a38a4f

Please sign in to comment.