Merge pull request #50 from drift-labs/master

mainnet push
This commit is contained in:
Nour Alharithi
2023-12-12 11:38:50 -08:00
committed by GitHub
3 changed files with 14 additions and 5 deletions

View File

@@ -941,7 +941,7 @@ const main = async () => {
let l2Formatted: any;
if (useRedis) {
if (
marketType === 'perp' &&
!isSpot &&
normedParam['includeVamm'].toLowerCase() === 'true' &&
normedParam['includeOracle'].toLowerCase() === 'true' &&
!normedParam['grouping']
@@ -966,7 +966,7 @@ const main = async () => {
l2Formatted = parsedRedisL2;
}
} else if (
marketType === 'spot' &&
isSpot &&
normedParam['includePhoenix'].toLowerCase() === 'true' &&
normedParam['includeSerum'].toLowerCase() === 'true' &&
!normedParam['grouping']

View File

@@ -60,7 +60,7 @@ const useOrderSubscriber =
const useGrpc = process.env.USE_GRPC?.toLowerCase() === 'true';
const useWebsocket = process.env.USE_WEBSOCKET?.toLowerCase() === 'true';
const ORDERBOOK_UPDATE_INTERVAL = useGrpc ? 500 : 1000;
const ORDERBOOK_UPDATE_INTERVAL = 1000;
const WS_FALLBACK_FETCH_INTERVAL = 10_000;
logger.info(`RPC endpoint: ${endpoint}`);

View File

@@ -103,7 +103,7 @@ async function main() {
const subscribers = channelSubscribers.get(subscribedChannel);
if (subscribers) {
subscribers.forEach((ws) => {
if (ws.readyState === WebSocket.OPEN && ws.bufferedAmount < 20)
if (ws.readyState === WebSocket.OPEN && ws.bufferedAmount < 100)
ws.send(
JSON.stringify({ channel: subscribedChannel, data: message })
);
@@ -257,6 +257,15 @@ async function main() {
ws.on('error', (error) => {
console.error('Socket error:', error);
});
// Set interval to send heartbeat every 5 seconds
setInterval(() => {
ws.send(
JSON.stringify({
channel: 'heartbeat',
})
);
}, 5000);
});
server.listen(WS_PORT, () => {
@@ -279,7 +288,7 @@ async function main() {
set = new Set([...set, ...wsSet]);
}
for (const ws of set) {
if (ws.bufferedAmount > 500) {
if (ws.bufferedAmount > 100) {
ws.close();
}
}