Skip to content

Commit ccf0244

Browse files
authored
feat(explorer): take batch ttl from env (#1667)
1 parent 0fa2ae5 commit ccf0244

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

explorer/.env.dev

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ DEBUG_ERRORS=true
2222
TRACKER_API_URL=http://localhost:3030
2323

2424
MAX_BATCH_SIZE=268435456 # 256 MiB
25+
26+
# Time we wait for a batch to be verified before marking it stale
27+
BATCH_TTL_MINUTES=5

explorer/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ DEBUG_ERRORS=<true|false>
2020

2121
# Tracker API
2222
TRACKER_API_URL=<tracker_api_url>
23+
24+
# Time we wait for a batch to be verified before marking it stale
25+
BATCH_TTL_MINUTES=5

explorer/lib/explorer_web/live/utils.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ defmodule ExplorerWeb.Helpers do
148148
end
149149

150150
def is_stale?(batch) do
151-
DateTime.add(batch.submission_timestamp, 5, :minute)
151+
ttl = Utils.batch_ttl_minutes()
152+
DateTime.add(batch.submission_timestamp, ttl, :minute)
152153
|> DateTime.before?(DateTime.utc_now())
153154
end
154155

@@ -297,6 +298,11 @@ defmodule Utils do
297298
end
298299
end
299300

301+
def batch_ttl_minutes() do
302+
System.get_env("BATCH_TTL_MINUTES")
303+
|> String.to_integer()
304+
end
305+
300306
def process_batch(%BatchDB{} = batch) do
301307
case get_proof_hashes(batch) do
302308
{:ok, proof_hashes} ->

explorer/start.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ env_vars=(
1515
"DEBUG_ERRORS"
1616
"TRACKER_API_URL"
1717
"MAX_BATCH_SIZE"
18+
"BATCH_TTL_MINUTES"
1819
)
1920

2021
for var in "${env_vars[@]}"; do

0 commit comments

Comments
 (0)