Skip to content

Commit

Permalink
add confirmationDepth setting too
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed May 3, 2024
1 parent cef3eff commit 691c36f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ export class ParallelEvmFunnel extends BaseFunnel implements ChainFunnel {
return newEntry;
})();

cacheEntry.updateState(config.chainId, latestBlock);
cacheEntry.updateState(config.chainId, latestBlock - (config.confirmationDepth ?? 0));

const evmCacheEntry = ((): EvmFunnelCacheEntry => {
const entry = sharedData.cacheManager.cacheEntries[EvmFunnelCacheEntry.SYMBOL];
Expand Down Expand Up @@ -513,12 +513,14 @@ export class ParallelEvmFunnel extends BaseFunnel implements ChainFunnel {
GET_BLOCK_NUMBER_TIMEOUT
);

const delayedBlock = newLatestBlock - Math.max(this.config.confirmationDepth ?? 0, 0);

this.sharedData.cacheManager.cacheEntries[RpcCacheEntry.SYMBOL]?.updateState(
this.config.chainId,
newLatestBlock
delayedBlock
);

return newLatestBlock;
return delayedBlock;
}

private getState(): EvmFunnelCacheEntryState {
Expand Down
1 change: 1 addition & 0 deletions packages/paima-sdk/paima-utils/src/config/loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const MainNetworkDiscrimination = Type.Union([
}),
Type.Object({
delay: Type.Optional(Type.Number()),
confirmationDepth: Type.Optional(Type.Number()),
type: Type.Literal(ConfigNetworkType.EVM_OTHER),
}),
]);
Expand Down

0 comments on commit 691c36f

Please sign in to comment.