Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Use cache for tps component (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrchatruc authored Sep 27, 2023
1 parent e018579 commit d07c7f7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/starknet_explorer_web/live/tps_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ defmodule StarknetExplorerWeb.Component.TransactionsPerSecond do
end

defp calculate_tps(network) do
result = Block.latest_blocks_with_txs(2, network)
result = StarknetExplorer.IndexCache.latest_blocks(network)

if length(result) < 2 do
0
else
[current_block, previous_block] = result
[current_block | [previous_block | _]] = result
curr_block_time = current_block.timestamp - previous_block.timestamp

tx_amount = Enum.count(current_block.transactions)
Expand Down

0 comments on commit d07c7f7

Please sign in to comment.