From c467a260b56b09e9b82115c51575d22b0fccb25a Mon Sep 17 00:00:00 2001 From: xiaoch05 Date: Thu, 18 Jan 2024 11:42:52 +0800 Subject: [PATCH] filter offline relayers --- apollo/src/aggregation/aggregation.resolver.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apollo/src/aggregation/aggregation.resolver.ts b/apollo/src/aggregation/aggregation.resolver.ts index 8d3ac9b2..dce577ad 100644 --- a/apollo/src/aggregation/aggregation.resolver.ts +++ b/apollo/src/aggregation/aggregation.resolver.ts @@ -5,6 +5,7 @@ import { Prisma } from '@prisma/client'; @Resolver() export class AggregationResolver { + private readonly heartbeatTimeout = 300; constructor(private aggregationService: AggregationService) {} @Query() @@ -302,6 +303,7 @@ export class AggregationResolver { // query all pending txs var sortedRelayers = []; var transferLimit = BigInt(0); + const now = Math.floor(Date.now() / 1000); for (const record of records.records) { const limit = record.version == 'lnv2' ? BigInt(record.margin) : BigInt(record.transferLimit); if (limit > transferLimit) { @@ -311,6 +313,10 @@ export class AggregationResolver { if (limit < BigInt(amount) + providerFee + BigInt(record.protocolFee) || record.paused) { continue; } + // offline + if (record.heartbeatTimestamp + this.heartbeatTimeout < now) { + continue; + } const point = await this.aggregationService.calculateLnBridgeRelayerPoint( token, BigInt(amount),