Skip to content

Commit

Permalink
switching to confirmed + trades resource reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
NourAlharithi committed Feb 22, 2024
1 parent b940eee commit a920160
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const commitHash = process.env.COMMIT;
//@ts-ignore
const sdkConfig = initialize({ env: process.env.ENV });

const stateCommitment: Commitment = 'processed';
const stateCommitment: Commitment = 'confirmed';
const serverPort = process.env.PORT || 6969;
export const ORDERBOOK_UPDATE_INTERVAL = 1000;
const WS_FALLBACK_FETCH_INTERVAL = ORDERBOOK_UPDATE_INTERVAL * 10;
Expand Down
2 changes: 1 addition & 1 deletion src/publishers/dlobPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import FEATURE_FLAGS from '../utils/featureFlags';
import { GeyserOrderSubscriber } from '../grpc/OrderSubscriberGRPC';

require('dotenv').config();
const stateCommitment: Commitment = 'processed';
const stateCommitment: Commitment = 'confirmed';
const driftEnv = (process.env.ENV || 'devnet') as DriftEnv;
const commitHash = process.env.COMMIT;
const REDIS_HOST = process.env.REDIS_HOST || 'localhost';
Expand Down
29 changes: 4 additions & 25 deletions src/publishers/tradesPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import {
initialize,
DriftEnv,
SlotSubscriber,
UserMap,
Wallet,
BulkAccountLoader,
EventSubscriber,
OrderAction,
convertToNumber,
Expand Down Expand Up @@ -38,9 +36,7 @@ const REDIS_PASSWORD = process.env.REDIS_PASSWORD;
//@ts-ignore
const sdkConfig = initialize({ env: process.env.ENV });

const stateCommitment: Commitment = 'processed';
const ORDERBOOK_UPDATE_INTERVAL = 1000;

const stateCommitment: Commitment = 'confirmed';
let driftClient: DriftClient;

const opts = program.opts();
Expand All @@ -62,19 +58,14 @@ const main = async () => {
commitment: stateCommitment,
});

const bulkAccountLoader = new BulkAccountLoader(
connection,
stateCommitment,
ORDERBOOK_UPDATE_INTERVAL
);

driftClient = new DriftClient({
connection,
wallet,
programID: clearingHousePublicKey,
accountSubscription: {
type: 'polling',
accountLoader: bulkAccountLoader,
type: 'websocket',
commitment: stateCommitment,
resubTimeoutMs: 30_000,
},
env: driftEnv,
});
Expand All @@ -96,18 +87,6 @@ const main = async () => {

await slotSubscriber.subscribe();

const userMap = new UserMap({
driftClient,
subscriptionConfig: {
type: 'websocket',
resubTimeoutMs: 30_000,
commitment: stateCommitment,
},
skipInitialLoad: false,
includeIdle: false,
});
await userMap.subscribe();

const redisClient = new RedisClient(REDIS_HOST, REDIS_PORT, REDIS_PASSWORD);
await redisClient.connect();

Expand Down

0 comments on commit a920160

Please sign in to comment.