mirror of
https://github.com/fdundjer/solana-sniper-bot.git
synced 2025-11-09 20:12:06 +10:00
35 lines
817 B
TypeScript
35 lines
817 B
TypeScript
import fs from 'fs';
|
|
import path from 'path';
|
|
import { logger, SNIPE_LIST_REFRESH_INTERVAL } from '../helpers';
|
|
|
|
export class SnipeListCache {
|
|
private snipeList: string[] = [];
|
|
|
|
constructor() {
|
|
setInterval(this.loadSnipeList, SNIPE_LIST_REFRESH_INTERVAL);
|
|
}
|
|
|
|
public init() {
|
|
this.loadSnipeList();
|
|
}
|
|
|
|
public isInList(mint: string) {
|
|
return this.snipeList.includes(mint);
|
|
}
|
|
|
|
private loadSnipeList() {
|
|
logger.trace('Refreshing snipe list...');
|
|
|
|
const count = this.snipeList.length;
|
|
const data = fs.readFileSync(path.join(__dirname, 'snipe-list.txt'), 'utf-8');
|
|
this.snipeList = data
|
|
.split('\n')
|
|
.map((a) => a.trim())
|
|
.filter((a) => a);
|
|
|
|
if (this.snipeList.length != count) {
|
|
logger.info(`Loaded snipe list: ${this.snipeList.length}`);
|
|
}
|
|
}
|
|
}
|