Merge pull request #459 from drift-labs/jack/ignore-list

chore: test out a dlob ignore list
This commit is contained in:
jack
2025-07-22 12:41:22 +10:00
committed by GitHub
2 changed files with 38 additions and 1 deletions

View File

@@ -0,0 +1,35 @@
import {
OrderSubscriber,
OrderSubscriberConfig,
UserAccount,
} from '@drift-labs/sdk';
export class OrderSubscriberFiltered extends OrderSubscriber {
public ignoreList: string[];
constructor(
config: OrderSubscriberConfig & {
ignoreList?: string[];
}
) {
super(config);
this.ignoreList = config.ignoreList ?? [];
}
override async tryUpdateUserAccount(
key: string,
dataType: 'raw' | 'decoded' | 'buffer',
data: string[] | UserAccount | Buffer,
slot: number
) {
if (!this.mostRecentSlot || slot > this.mostRecentSlot) {
this.mostRecentSlot = slot;
}
if (this.ignoreList.includes(key)) {
return;
}
super.tryUpdateUserAccount(key, dataType, data, slot);
}
}

View File

@@ -47,6 +47,7 @@ import express, { Response, Request } from 'express';
import { handleHealthCheck } from '../core/middleware'; import { handleHealthCheck } from '../core/middleware';
import { setGlobalDispatcher, Agent } from 'undici'; import { setGlobalDispatcher, Agent } from 'undici';
import { Metrics } from '../core/metricsV2'; import { Metrics } from '../core/metricsV2';
import { OrderSubscriberFiltered } from '../dlob-subscriber/OrderSubscriberFiltered';
setGlobalDispatcher( setGlobalDispatcher(
new Agent({ new Agent({
@@ -474,9 +475,10 @@ const main = async () => {
}; };
} }
const orderSubscriber = new OrderSubscriber({ const orderSubscriber = new OrderSubscriberFiltered({
driftClient, driftClient,
subscriptionConfig, subscriptionConfig,
ignoreList: ['5N1AcdftujhXWZdBaqfciaKtXn6uVBKjmgwf6aQxR1vW']
}); });
dlobProvider = getDLOBProviderFromOrderSubscriber(orderSubscriber); dlobProvider = getDLOBProviderFromOrderSubscriber(orderSubscriber);