Merge branch 'master' into mainnet-beta
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@drift-labs/sdk": "2.48.0-beta.9",
|
"@drift-labs/sdk": "2.48.0-beta.13",
|
||||||
"@opentelemetry/api": "^1.1.0",
|
"@opentelemetry/api": "^1.1.0",
|
||||||
"@opentelemetry/auto-instrumentations-node": "^0.31.1",
|
"@opentelemetry/auto-instrumentations-node": "^0.31.1",
|
||||||
"@opentelemetry/exporter-prometheus": "^0.31.0",
|
"@opentelemetry/exporter-prometheus": "^0.31.0",
|
||||||
|
|||||||
@@ -134,12 +134,11 @@ const handleHealthCheck = async (req, res, next) => {
|
|||||||
if (lastHealthCheckState) {
|
if (lastHealthCheckState) {
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end('OK');
|
res.end('OK');
|
||||||
} else {
|
lastHealthCheckPerformed = Date.now();
|
||||||
res.writeHead(500);
|
|
||||||
res.end(`NOK`);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// always check if last check was unhealthy (give it another chance to recover)
|
||||||
|
}
|
||||||
|
|
||||||
const { lastSlotReceived, lastSlotReceivedMutex } = getSlotHealthCheckInfo();
|
const { lastSlotReceived, lastSlotReceivedMutex } = getSlotHealthCheckInfo();
|
||||||
|
|
||||||
@@ -149,7 +148,9 @@ const handleHealthCheck = async (req, res, next) => {
|
|||||||
lastHealthCheckState = lastSlotReceived > lastHealthCheckSlot;
|
lastHealthCheckState = lastSlotReceived > lastHealthCheckSlot;
|
||||||
if (!lastHealthCheckState) {
|
if (!lastHealthCheckState) {
|
||||||
logger.error(
|
logger.error(
|
||||||
`Unhealthy: lastSlot: ${lastSlotReceived}, lastHealthCheckSlot: ${lastHealthCheckSlot}`
|
`Unhealthy: lastSlot: ${lastSlotReceived}, lastHealthCheckSlot: ${lastHealthCheckSlot}, timeSinceLastCheck: ${
|
||||||
|
Date.now() - lastHealthCheckPerformed
|
||||||
|
} ms`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
24
src/index.ts
24
src/index.ts
@@ -21,8 +21,8 @@ import {
|
|||||||
SlotSource,
|
SlotSource,
|
||||||
SlotSubscriber,
|
SlotSubscriber,
|
||||||
UserMap,
|
UserMap,
|
||||||
UserStatsMap,
|
|
||||||
Wallet,
|
Wallet,
|
||||||
|
getUserStatsAccountPublicKey,
|
||||||
getVariant,
|
getVariant,
|
||||||
groupL2,
|
groupL2,
|
||||||
initialize,
|
initialize,
|
||||||
@@ -231,8 +231,6 @@ const main = async () => {
|
|||||||
lastSlotReceived = slotSource.getSlot();
|
lastSlotReceived = slotSource.getSlot();
|
||||||
}, ORDERBOOK_UPDATE_INTERVAL);
|
}, ORDERBOOK_UPDATE_INTERVAL);
|
||||||
|
|
||||||
const userStatsMap = new UserStatsMap(driftClient);
|
|
||||||
|
|
||||||
logger.info(`Initializing userMap...`);
|
logger.info(`Initializing userMap...`);
|
||||||
const initUserMapStart = Date.now();
|
const initUserMapStart = Date.now();
|
||||||
const userMap = new UserMap(
|
const userMap = new UserMap(
|
||||||
@@ -243,12 +241,6 @@ const main = async () => {
|
|||||||
await userMap.subscribe();
|
await userMap.subscribe();
|
||||||
logger.info(`userMap initialized in ${Date.now() - initUserMapStart} ms`);
|
logger.info(`userMap initialized in ${Date.now() - initUserMapStart} ms`);
|
||||||
|
|
||||||
const initUserStatsMapStarts = Date.now();
|
|
||||||
await userStatsMap.sync(userMap.getUniqueAuthorities());
|
|
||||||
logger.info(
|
|
||||||
`userStatsMap initialized in ${Date.now() - initUserStatsMapStarts} ms`
|
|
||||||
);
|
|
||||||
|
|
||||||
logger.info(`Initializing DLOBSubscriber...`);
|
logger.info(`Initializing DLOBSubscriber...`);
|
||||||
const initDlobSubscriberStart = Date.now();
|
const initDlobSubscriberStart = Date.now();
|
||||||
const dlobSubscriber = new DLOBSubscriber({
|
const dlobSubscriber = new DLOBSubscriber({
|
||||||
@@ -265,11 +257,7 @@ const main = async () => {
|
|||||||
MARKET_SUBSCRIBERS = await initializeAllMarketSubscribers(driftClient);
|
MARKET_SUBSCRIBERS = await initializeAllMarketSubscribers(driftClient);
|
||||||
|
|
||||||
const handleStartup = async (_req, res, _next) => {
|
const handleStartup = async (_req, res, _next) => {
|
||||||
if (
|
if (driftClient.isSubscribed && userMap.size() > 0) {
|
||||||
driftClient.isSubscribed &&
|
|
||||||
userMap.size() > 0 &&
|
|
||||||
userStatsMap.size() > 0
|
|
||||||
) {
|
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end('OK');
|
res.end('OK');
|
||||||
} else {
|
} else {
|
||||||
@@ -559,12 +547,12 @@ const main = async () => {
|
|||||||
if (`${includeUserStats}`.toLowerCase() === 'true') {
|
if (`${includeUserStats}`.toLowerCase() === 'true') {
|
||||||
const userAccount = side.userAccount.toBase58();
|
const userAccount = side.userAccount.toBase58();
|
||||||
await userMap.mustGet(userAccount);
|
await userMap.mustGet(userAccount);
|
||||||
const userStats = await userStatsMap.mustGet(
|
|
||||||
userMap.getUserAuthority(userAccount)!.toBase58()
|
|
||||||
);
|
|
||||||
topMakers.add([
|
topMakers.add([
|
||||||
userAccount,
|
userAccount,
|
||||||
userStats.userStatsAccountPublicKey.toBase58(),
|
getUserStatsAccountPublicKey(
|
||||||
|
driftClient.program.programId,
|
||||||
|
userMap.getUserAuthority(userAccount)
|
||||||
|
),
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
topMakers.add(side.userAccount.toBase58());
|
topMakers.add(side.userAccount.toBase58());
|
||||||
|
|||||||
@@ -80,10 +80,10 @@
|
|||||||
enabled "2.0.x"
|
enabled "2.0.x"
|
||||||
kuler "^2.0.0"
|
kuler "^2.0.0"
|
||||||
|
|
||||||
"@drift-labs/sdk@2.48.0-beta.9":
|
"@drift-labs/sdk@2.48.0-beta.13":
|
||||||
version "2.48.0-beta.9"
|
version "2.48.0-beta.13"
|
||||||
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.48.0-beta.9.tgz#2d0c99f58387ff3c5e45859ae4fe088339c8dd55"
|
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.48.0-beta.13.tgz#0ad1cfd4daac97e1859fe617a749a2676e462b63"
|
||||||
integrity sha512-y0wrq680nv7Uwvcg9jOrjZPXxoae9yRg8M9B4bQgDFeNJmZNmcEmnLhWQ+CbPi8u/O0glhOdtKUk4UF9eSPXAg==
|
integrity sha512-ogtY38Db44PVZOr8WwNHijnwVMBLFvIYNxmlE9BPehdEgIQ9PYT9QXalanhQ1Ruc/Cs5DbMIT3XvjtLyfFzEUg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@coral-xyz/anchor" "0.28.1-beta.2"
|
"@coral-xyz/anchor" "0.28.1-beta.2"
|
||||||
"@ellipsis-labs/phoenix-sdk" "^1.4.2"
|
"@ellipsis-labs/phoenix-sdk" "^1.4.2"
|
||||||
|
|||||||
Reference in New Issue
Block a user