Skip to content

Commit

Permalink
filter offline relayers
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoch05 committed Jan 18, 2024
1 parent e20e5d5 commit c467a26
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apollo/src/aggregation/aggregation.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Prisma } from '@prisma/client';

@Resolver()
export class AggregationResolver {
private readonly heartbeatTimeout = 300;
constructor(private aggregationService: AggregationService) {}

@Query()
Expand Down Expand Up @@ -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) {
Expand All @@ -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),
Expand Down

0 comments on commit c467a26

Please sign in to comment.