Merge pull request #68 from drift-labs/send-ack
attach ts and send ack on subscribe
This commit is contained in:
@@ -124,6 +124,7 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
l2Formatted['marketName'] = marketName?.toUpperCase();
|
l2Formatted['marketName'] = marketName?.toUpperCase();
|
||||||
l2Formatted['marketType'] = marketType?.toLowerCase();
|
l2Formatted['marketType'] = marketType?.toLowerCase();
|
||||||
l2Formatted['marketIndex'] = l2Args.marketIndex;
|
l2Formatted['marketIndex'] = l2Args.marketIndex;
|
||||||
|
l2Formatted['ts'] = Date.now();
|
||||||
l2Formatted['slot'] = slot;
|
l2Formatted['slot'] = slot;
|
||||||
addOracletoResponse(
|
addOracletoResponse(
|
||||||
l2Formatted,
|
l2Formatted,
|
||||||
@@ -137,7 +138,7 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
l2Args.marketType,
|
l2Args.marketType,
|
||||||
l2Args.marketIndex
|
l2Args.marketIndex
|
||||||
);
|
);
|
||||||
|
|
||||||
const l2Formatted_depth100 = Object.assign({}, l2Formatted, {
|
const l2Formatted_depth100 = Object.assign({}, l2Formatted, {
|
||||||
bids: l2Formatted.bids.slice(0, 100),
|
bids: l2Formatted.bids.slice(0, 100),
|
||||||
asks: l2Formatted.asks.slice(0, 100),
|
asks: l2Formatted.asks.slice(0, 100),
|
||||||
|
|||||||
@@ -140,9 +140,13 @@ export const addMarketSlotToResponse = (
|
|||||||
): void => {
|
): void => {
|
||||||
let marketSlot: number;
|
let marketSlot: number;
|
||||||
if (isVariant(marketType, 'perp')) {
|
if (isVariant(marketType, 'perp')) {
|
||||||
marketSlot = driftClient.accountSubscriber.getMarketAccountAndSlot(marketIndex).slot;
|
marketSlot =
|
||||||
|
driftClient.accountSubscriber.getMarketAccountAndSlot(marketIndex).slot;
|
||||||
} else {
|
} else {
|
||||||
marketSlot = driftClient.accountSubscriber.getSpotMarketAccountAndSlot(marketIndex).slot;
|
marketSlot =
|
||||||
|
driftClient.accountSubscriber.getSpotMarketAccountAndSlot(
|
||||||
|
marketIndex
|
||||||
|
).slot;
|
||||||
}
|
}
|
||||||
response['marketSlot'] = marketSlot;
|
response['marketSlot'] = marketSlot;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -164,12 +164,16 @@ async function main() {
|
|||||||
.subscribe(redisChannel)
|
.subscribe(redisChannel)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
subscribedChannels.add(redisChannel);
|
subscribedChannels.add(redisChannel);
|
||||||
|
ws.send(
|
||||||
|
JSON.stringify({
|
||||||
|
message: `Subscribe received for channel: ${parsedMessage.channel}, market: ${parsedMessage.market}, marketType: ${parsedMessage.marketType}`,
|
||||||
|
})
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
ws.send(
|
ws.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
redisChannel,
|
error: `Error subscribing to channel: ${parsedMessage}`,
|
||||||
error: `Error subscribing to channel: ${redisChannel}`,
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@@ -198,6 +202,7 @@ async function main() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'unsubscribe': {
|
case 'unsubscribe': {
|
||||||
|
|||||||
Reference in New Issue
Block a user