Skip to content

Commit

Permalink
fix: skip empty requests
Browse files Browse the repository at this point in the history
  • Loading branch information
doomsower committed Aug 27, 2024
1 parent 2371393 commit 5610b6f
Showing 1 changed file with 16 additions and 23 deletions.
39 changes: 16 additions & 23 deletions src/services/RedstoneServiceV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ import type { PriceOnDemandExtras, PriceUpdate } from "./liquidate/index.js";
import type { RedstoneFeed } from "./OracleServiceV3.js";
import type OracleServiceV3 from "./OracleServiceV3.js";

interface RedstoneRequest {
originalToken: Address;
tokenOrTicker: Address;
reserve: boolean;
dataFeedId: string;
}

interface TimestampedCalldata {
callData: `0x${string}`;
ts: number;
Expand All @@ -59,12 +52,6 @@ export type RedstonePriceFeed = Extract<
{ type: PriceFeedType.REDSTONE_ORACLE }
>;

const HISTORICAL_BLOCKLIST = new Set<string>([
// "rsETH_FUNDAMENTAL",
// "weETH_FUNDAMENTAL",
// "ezETH_FUNDAMENTAL",
]);

@DI.Injectable(DI.Redstone)
export class RedstoneServiceV3 {
@Logger("Redstone")
Expand Down Expand Up @@ -327,6 +314,7 @@ export class RedstoneServiceV3 {
const cacheAllowed = this.config.optimistic;

const networkUpdates: RedstoneUpdate[] = [];
let networkResponses: PriceOnDemandExtras[] = [];
const cachedResponses: PriceOnDemandExtras[] = [];

for (const upd of updates) {
Expand All @@ -339,16 +327,21 @@ export class RedstoneServiceV3 {
}
}

const networkResponses = await this.#fetchRedstonePayloadForManualUsage(
networkUpdates,
dataServiceId,
uniqueSignersCount,
);

if (cacheAllowed) {
for (const resp of networkResponses) {
const key = redstoneCacheKey(resp, dataServiceId, uniqueSignersCount);
this.#optimisticCache.set(key, resp);
if (networkUpdates.length) {
logger.debug(
`fetching ${networkUpdates.length} redstone updates: ${printFeeds(networkUpdates)}`,
);
networkResponses = await this.#fetchRedstonePayloadForManualUsage(
networkUpdates,
dataServiceId,
uniqueSignersCount,
);
if (cacheAllowed) {
for (const resp of networkResponses) {
const key = redstoneCacheKey(resp, dataServiceId, uniqueSignersCount);
this.#optimisticCache.set(key, resp);
logger.debug(`cached response for ${key}`);
}
}
}

Expand Down

0 comments on commit 5610b6f

Please sign in to comment.