Merge pull request #68 from drift-labs/send-ack

attach ts and send ack on subscribe
This commit is contained in:
Nour Alharithi
2024-01-19 13:33:09 -08:00
committed by GitHub
3 changed files with 15 additions and 5 deletions

View File

@@ -124,6 +124,7 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
l2Formatted['marketName'] = marketName?.toUpperCase();
l2Formatted['marketType'] = marketType?.toLowerCase();
l2Formatted['marketIndex'] = l2Args.marketIndex;
l2Formatted['ts'] = Date.now();
l2Formatted['slot'] = slot;
addOracletoResponse(
l2Formatted,

View File

@@ -140,9 +140,13 @@ export const addMarketSlotToResponse = (
): void => {
let marketSlot: number;
if (isVariant(marketType, 'perp')) {
marketSlot = driftClient.accountSubscriber.getMarketAccountAndSlot(marketIndex).slot;
marketSlot =
driftClient.accountSubscriber.getMarketAccountAndSlot(marketIndex).slot;
} else {
marketSlot = driftClient.accountSubscriber.getSpotMarketAccountAndSlot(marketIndex).slot;
marketSlot =
driftClient.accountSubscriber.getSpotMarketAccountAndSlot(
marketIndex
).slot;
}
response['marketSlot'] = marketSlot;
};

View File

@@ -164,12 +164,16 @@ async function main() {
.subscribe(redisChannel)
.then(() => {
subscribedChannels.add(redisChannel);
ws.send(
JSON.stringify({
message: `Subscribe received for channel: ${parsedMessage.channel}, market: ${parsedMessage.market}, marketType: ${parsedMessage.marketType}`,
})
);
})
.catch(() => {
ws.send(
JSON.stringify({
redisChannel,
error: `Error subscribing to channel: ${redisChannel}`,
error: `Error subscribing to channel: ${parsedMessage}`,
})
);
return;
@@ -198,6 +202,7 @@ async function main() {
);
}
}
break;
}
case 'unsubscribe': {