|
|
@@ -5,27 +5,29 @@ import { redisCache } from "../../cache";
|
|
|
const _getPublishersByFeedForCluster = async (cluster: Cluster) => {
|
|
|
const data = await getPythMetadata(cluster);
|
|
|
const result: Record<string, string[]> = {};
|
|
|
- for (const key of data.productPrice.keys()) {
|
|
|
- const price = data.productPrice.get(key);
|
|
|
- result[key] =
|
|
|
- price?.priceComponents.map(({ publisher }) => publisher.toBase58()) ?? [];
|
|
|
+ for (const [key, price] of data.productPrice.entries()) {
|
|
|
+ result[key] = price.priceComponents.map(({ publisher }) =>
|
|
|
+ publisher.toBase58(),
|
|
|
+ );
|
|
|
}
|
|
|
return result;
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * Given a cluster, this function will return a record which maps each
|
|
|
+ * permissioned publisher to the list of price feed IDs for which that publisher
|
|
|
+ * is permissioned.
|
|
|
+ */
|
|
|
const _getFeedsByPublisherForCluster = async (cluster: Cluster) => {
|
|
|
const data = await getPythMetadata(cluster);
|
|
|
const result: Record<string, string[]> = {};
|
|
|
- for (const symbol of data.productPrice.keys()) {
|
|
|
- const price = data.productPrice.get(symbol);
|
|
|
- if (price !== undefined) {
|
|
|
- for (const component of price.priceComponents) {
|
|
|
- const publisherKey = component.publisher.toBase58();
|
|
|
- if (result[publisherKey] === undefined) {
|
|
|
- result[publisherKey] = [symbol];
|
|
|
- } else {
|
|
|
- result[publisherKey].push(symbol);
|
|
|
- }
|
|
|
+ for (const [symbol, price] of data.productPrice.entries()) {
|
|
|
+ for (const component of price.priceComponents) {
|
|
|
+ const publisherKey = component.publisher.toBase58();
|
|
|
+ if (result[publisherKey] === undefined) {
|
|
|
+ result[publisherKey] = [symbol];
|
|
|
+ } else {
|
|
|
+ result[publisherKey].push(symbol);
|
|
|
}
|
|
|
}
|
|
|
}
|