publishing messages
This commit is contained in:
40
src/index.ts
40
src/index.ts
@@ -17,7 +17,6 @@ import {
|
||||
DLOBOrder,
|
||||
DLOBOrders,
|
||||
DLOBOrdersCoder,
|
||||
MarketType,
|
||||
DLOBNode,
|
||||
isVariant,
|
||||
BN,
|
||||
@@ -39,7 +38,6 @@ import {
|
||||
errorHandler,
|
||||
getPhoenixSubscriber,
|
||||
getSerumSubscriber,
|
||||
validateWsSubscribeMsg,
|
||||
validateDlobQuery,
|
||||
} from './utils/utils';
|
||||
import { DLOBSubscriberIO } from './dlob-subscriber/DLOBSubscriberIO';
|
||||
@@ -54,7 +52,7 @@ const sdkConfig = initialize({ env: process.env.ENV });
|
||||
|
||||
const stateCommitment: Commitment = 'processed';
|
||||
const serverPort = process.env.PORT || 6969;
|
||||
const ORDERBOOK_UPDATE_INTERVAL = 100;
|
||||
const ORDERBOOK_UPDATE_INTERVAL = 1000;
|
||||
|
||||
const rateLimitCallsPerSecond = process.env.RATE_LIMIT_CALLS_PER_SECOND
|
||||
? parseInt(process.env.RATE_LIMIT_CALLS_PER_SECOND)
|
||||
@@ -162,7 +160,6 @@ const main = async () => {
|
||||
programID: clearingHousePublicKey,
|
||||
accountSubscription: {
|
||||
type: 'websocket',
|
||||
resubTimeoutMs: 60000,
|
||||
},
|
||||
env: driftEnv,
|
||||
userStats: true,
|
||||
@@ -813,41 +810,6 @@ const main = async () => {
|
||||
socket.on('disconnect', () => {
|
||||
console.log('user disconnected');
|
||||
});
|
||||
|
||||
socket.on('message', (msg: any) => {
|
||||
const parsed = JSON.parse(msg);
|
||||
if (parsed['type'] == 'subscribe') {
|
||||
const valid = validateWsSubscribeMsg(parsed);
|
||||
if (!valid.valid) {
|
||||
socket.emit('message', {
|
||||
type: 'error',
|
||||
message: `Bad Request: Invalid subscribe message: ${valid.msg}`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
dlobSubscriber.marketL2Args.push({
|
||||
marketIndex: parseInt(parsed['marketIndex']),
|
||||
marketType: isVariant(parsed['marketType'].toLowerCase(), 'spot')
|
||||
? MarketType.SPOT
|
||||
: MarketType.PERP,
|
||||
marketName: parsed['marketName'],
|
||||
depth: parseInt(parsed['depth']),
|
||||
includeVamm: parsed['includeVamm'] === 'true',
|
||||
grouping: parsed['grouping']
|
||||
? parseInt(parsed['grouping'])
|
||||
: undefined,
|
||||
fallbackL2Generators: isVariant(parsed['marketType'], 'spot')
|
||||
? [
|
||||
`${parsed['includePhoenix']}`.toLowerCase() === 'true' &&
|
||||
MARKET_SUBSCRIBERS[parseInt(parsed['marketIndex'])].phoenix,
|
||||
`${parsed['includeSerum']}`.toLowerCase() === 'true' &&
|
||||
MARKET_SUBSCRIBERS[parseInt(parsed['marketIndex'])].serum,
|
||||
].filter((a) => !!a)
|
||||
: [],
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user