Merge branch 'master' into crispheaney/order-subscriber
This commit is contained in:
@@ -134,11 +134,10 @@ 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);
|
return;
|
||||||
res.end(`NOK`);
|
|
||||||
}
|
}
|
||||||
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,
|
||||||
@@ -275,8 +275,6 @@ const main = async () => {
|
|||||||
lastSlotReceived = slotSource.getSlot();
|
lastSlotReceived = slotSource.getSlot();
|
||||||
}, ORDERBOOK_UPDATE_INTERVAL);
|
}, ORDERBOOK_UPDATE_INTERVAL);
|
||||||
|
|
||||||
const userStatsMap = new UserStatsMap(driftClient);
|
|
||||||
|
|
||||||
logger.info(`Initializing DLOB Provider...`);
|
logger.info(`Initializing DLOB Provider...`);
|
||||||
const initUserMapStart = Date.now();
|
const initUserMapStart = Date.now();
|
||||||
await dlobProvider.subscribe();
|
await dlobProvider.subscribe();
|
||||||
@@ -285,12 +283,6 @@ const main = async () => {
|
|||||||
);
|
);
|
||||||
logger.info(`dlob provider size ${dlobProvider.size()}`);
|
logger.info(`dlob provider size ${dlobProvider.size()}`);
|
||||||
|
|
||||||
const initUserStatsMapStarts = Date.now();
|
|
||||||
await userStatsMap.sync(dlobProvider.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({
|
||||||
@@ -307,11 +299,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 && dlobProvider.size() > 0) {
|
||||||
driftClient.isSubscribed &&
|
|
||||||
dlobProvider.size() > 0 &&
|
|
||||||
userStatsMap.size() > 0
|
|
||||||
) {
|
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end('OK');
|
res.end('OK');
|
||||||
} else {
|
} else {
|
||||||
@@ -594,12 +582,12 @@ const main = async () => {
|
|||||||
const userAccount = dlobProvider.getUserAccount(
|
const userAccount = dlobProvider.getUserAccount(
|
||||||
side.userAccount
|
side.userAccount
|
||||||
);
|
);
|
||||||
const userStats = await userStatsMap.mustGet(
|
|
||||||
userAccount.authority.toBase58()
|
|
||||||
);
|
|
||||||
topMakers.add([
|
topMakers.add([
|
||||||
userAccount,
|
userAccount,
|
||||||
userStats.userStatsAccountPublicKey.toBase58(),
|
getUserStatsAccountPublicKey(
|
||||||
|
driftClient.program.programId,
|
||||||
|
userAccount.authority
|
||||||
|
),
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
topMakers.add(side.userAccount.toBase58());
|
topMakers.add(side.userAccount.toBase58());
|
||||||
|
|||||||
Reference in New Issue
Block a user