Updated topMakers to return user accounts in buffer format
This commit is contained in:
@@ -45,6 +45,7 @@ import {
|
||||
sleep,
|
||||
validateDlobQuery,
|
||||
getAccountFromId,
|
||||
getRawAccountFromId,
|
||||
} from './utils/utils';
|
||||
import FEATURE_FLAGS from './utils/featureFlags';
|
||||
import { getDLOBProviderFromOrderSubscriber } from './dlobProvider';
|
||||
@@ -572,7 +573,10 @@ const main = async (): Promise<void> => {
|
||||
res.writeHead(200);
|
||||
|
||||
if (accountFlag) {
|
||||
const topAccounts = await getAccountFromId(userMapClient, topMakers);
|
||||
const topAccounts = await getRawAccountFromId(
|
||||
userMapClient,
|
||||
topMakers
|
||||
);
|
||||
res.end(JSON.stringify(topAccounts));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -364,6 +364,32 @@ export const getAccountFromId = async (
|
||||
).then((results) => results.filter((user) => !!user));
|
||||
};
|
||||
|
||||
export const getRawAccountFromId = async (
|
||||
userMapClient: RedisClient,
|
||||
topMakers: string[]
|
||||
): Promise<
|
||||
{
|
||||
userAccountPubKey: string;
|
||||
accountBase64: string;
|
||||
}[]
|
||||
> => {
|
||||
return Promise.all(
|
||||
topMakers.map(async (userAccountPubKey) => {
|
||||
const userAccountEncoded = await userMapClient.getRaw(userAccountPubKey);
|
||||
if (userAccountEncoded) {
|
||||
return {
|
||||
userAccountPubKey,
|
||||
accountBase64: userAccountEncoded.split('::')[1],
|
||||
};
|
||||
}
|
||||
return {
|
||||
userAccountPubKey,
|
||||
accountBase64: null,
|
||||
};
|
||||
})
|
||||
).then((results) => results.filter((user) => !!user));
|
||||
};
|
||||
|
||||
export function errorHandler(
|
||||
err: Error,
|
||||
_req: Request,
|
||||
|
||||
Reference in New Issue
Block a user