Skip to content

Commit

Permalink
add slothash subscriber and change default interval ms
Browse files Browse the repository at this point in the history
  • Loading branch information
NourAlharithi committed Nov 12, 2024
1 parent ca8a627 commit 94a9c8d
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/bots/switchboardCranker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
SlothashSubscriber,
TxSigAndSlot,
} from '@drift-labs/sdk';
import { SwitchboardOnDemandClient } from '@drift-labs/sdk';
import { BundleSender } from '../bundleSender';
import {
AddressLookupTableAccount,
Expand All @@ -29,9 +28,7 @@ const SIM_CU_ESTIMATE_MULTIPLIER = 1.5;
export class SwitchboardCrankerBot implements Bot {
public name: string;
public dryRun: boolean;
private intervalMs: number;
private oracleClient: SwitchboardOnDemandClient;
public defaultIntervalMs = 30_000;
public defaultIntervalMs: number;

private blockhashSubscriber: BlockhashSubscriber;
private slothashSubscriber: SlothashSubscriber;
Expand All @@ -46,15 +43,11 @@ export class SwitchboardCrankerBot implements Bot {
) {
this.name = crankConfigs.botId;
this.dryRun = crankConfigs.dryRun;
this.intervalMs = crankConfigs.intervalMs;
this.defaultIntervalMs = crankConfigs.intervalMs || 10_000;
this.blockhashSubscriber = new BlockhashSubscriber({
connection: driftClient.connection,
});

this.oracleClient = new SwitchboardOnDemandClient(
this.driftClient.connection
);

this.slothashSubscriber = new SlothashSubscriber(
this.driftClient.connection,
{
Expand All @@ -78,7 +71,7 @@ export class SwitchboardCrankerBot implements Bot {
await this.driftClient.unsubscribe();
}

async startIntervalLoop(intervalMs = this.intervalMs): Promise<void> {
async startIntervalLoop(intervalMs = this.defaultIntervalMs): Promise<void> {
logger.info(`Starting ${this.name} bot with interval ${intervalMs} ms`);
await sleepMs(5000);
await this.runCrankLoop();
Expand Down

0 comments on commit 94a9c8d

Please sign in to comment.