From 94f4331ba6f4cabab22639017ea475e820ee6417 Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Wed, 7 Aug 2024 02:34:26 +0100 Subject: [PATCH] format and more comments --- ts/client/scripts/sb-on-demand-crank.ts | 9 ++++++--- ts/client/src/accounts/healthCache.ts | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ts/client/scripts/sb-on-demand-crank.ts b/ts/client/scripts/sb-on-demand-crank.ts index e93f1cc8b..abe824e66 100644 --- a/ts/client/scripts/sb-on-demand-crank.ts +++ b/ts/client/scripts/sb-on-demand-crank.ts @@ -136,7 +136,9 @@ async function setupBackgroundRefresh( const startedAt = Date.now(); const [block, slot] = await Promise.all([ + // use finalized blockhash for faster timeouts on transactions client.connection.getLatestBlockhash('finalized'), + // use processed slot for accurate staleness measurement client.connection.getSlot('processed'), ]); @@ -269,7 +271,7 @@ async function setupBackgroundRefresh( `[tx send] https://solscan.io/tx/${data['txid']}, in ${total}s, lamportsPerCu_ ${lamportsPerCu_}, lamportsPerCu ${lamportsPerCu}, timiming ${JSON.stringify(timing)}`, ); }, - onError: function (e, notProcessedTransactions, _originalProps) { + onError: function (e, notProcessedTransactions) { console.error( `[tx send] ${notProcessedTransactions.length} error(s) after ${(Date.now() - ixPreparedAt) / 1000}s ${JSON.stringify(e)}`, ); @@ -308,7 +310,7 @@ async function preparePullIx( gateway: oracle.gatewayUrl, }; // TODO use fetchUpdateMany - const [pullIx, _responses, _success] = await pullFeed.fetchUpdateIx( + const [pullIx] = await pullFeed.fetchUpdateIx( conf, recentSlothashes, ); @@ -373,7 +375,8 @@ async function filterForStaleOracles( // maxStaleness will usually be 250 (=100s) // one iteration takes 10s, retry is every 20s // this allows for 2 retries until the oracle becomes stale - diff > item.decodedPullFeed.maxStaleness * 0.3 + diff > + item.decodedPullFeed.maxStaleness * 0.3 ) { console.log( `[filter stale] ${item.oracle.name}, candidate, ${item.decodedPullFeed.maxStaleness}, ${slot}, ${res.lastUpdatedSlot}, ${diff}`, diff --git a/ts/client/src/accounts/healthCache.ts b/ts/client/src/accounts/healthCache.ts index 54c774676..93fd3dbf9 100644 --- a/ts/client/src/accounts/healthCache.ts +++ b/ts/client/src/accounts/healthCache.ts @@ -949,7 +949,7 @@ export class HealthCache { // - be careful about finding the minFnValue: the function isn't convex const initialRatio = this.healthRatio(HealthType.init); - // eslint-disable-next-line @typescript-eslint/no-unused-vars + const healthCacheClone: HealthCache = deepClone(this); const sourceIndex = healthCacheClone.getOrCreateTokenInfoIndex(sourceBank);