Commit graph

214 commits

Author SHA1 Message Date
Dagur Valberg Johannsson
2301b45887 Merge branch 'blob' into 'master'
Convert hash columns from TEXT to BLOB storage

Closes #1

See merge request riftenlabs/riftenlabs-indexer!53
2026-01-22 15:20:38 +00:00
Dagur Valberg Johannsson
58fd9595d7
Convert hash columns from TEXT to BLOB storage
Migrate all 32-byte hash fields from TEXT (64-char hex) to BLOB
(32 bytes) for ~50% storage savings on hash columns.

Changes:
- Add src/db/blob.rs with ToBlob/FromBlob traits for hash types
- Update all table schemas to use BLOB for hash columns
- Replace .to_hex() with .to_blob() for DB inserts
- Replace ::from_hex() with ::from_blob() for DB reads
- Use SQL hex() function where API responses need hex strings
- Bump DB_VERSION from 4 to 5

Affected tables: tx, pool, pool_history_entry, utxo_spending,
utxo_funding, user_action, auth_chain_entry, bcmr_data,
bcmr_failure, bcmr_well_known, crc20, crc20_candidates,
delphi_entry, cached_token_metrics

Fixes #1
2026-01-22 08:30:17 +01:00
Dagur Valberg Johannsson
d41073d5b7 Merge branch 'aapy-fix' into 'master'
Fix APY overflow when period_start clips pool duration

Closes #18

See merge request riftenlabs/riftenlabs-indexer!55
2026-01-22 06:50:11 +00:00
Dagur Valberg Johannsson
cf702959ca Fix APY overflow when period_start clips pool duration
Interpolate sqrt(K) linearly when the API's period_start is after the
pool's snapshot timestamp. This ensures yield and duration are calculated
over the same effective period, preventing overflow from high yields
being annualized over short durations.

Added unit tests based on failing production data for token d03a0d87...

Fixes #18
2026-01-21 19:16:46 +01:00
Dagur Valberg Johannsson
27c7165633 Merge branch 'bug-bcmr' into 'master'
Fix token search dedup to prefer entries with metadata

Closes #7

See merge request riftenlabs/riftenlabs-indexer!54
2026-01-21 14:33:27 +00:00
Dagur Valberg Johannsson
be1499db7c
Fix token search dedup to prefer entries with metadata
When a token has both an auth_chain_entry (without BCMR) and a CRC20
entry (with name/symbol), the dedup logic now keeps the metadata
instead of returning NULL.
2026-01-21 15:23:42 +01:00
Dagur Valberg Johannsson
66097c1abb Merge branch 'copyright' into 'master'
Update copyright headers

See merge request riftenlabs/riftenlabs-indexer!52
2026-01-21 11:57:48 +00:00
Dagur Valberg Johannsson
d85bc2c9db
Update copyright headers 2026-01-21 12:37:13 +01:00
Dagur Valberg Johannsson
1dabcc756c Merge branch 'shutdown' into 'master'
Add graceful shutdown for background threads

See merge request riftenlabs/riftenlabs-indexer!51
2026-01-21 11:36:47 +00:00
Dagur Valberg Johannsson
ec20a2ad75 Add graceful shutdown for background threads
Introduce a shutdown flag and Rocket fairing that signals background
threads to exit cleanly when Ctrl+C is pressed. Affects the indexing
thread, metrics updater, and block receiver loop.
2026-01-21 12:23:08 +01:00
Dagur Valberg Johannsson
16ed485711 Merge branch 'bug-bcmr' into 'master'
Fix bcmr_failure unique constraint for multi-token transactions

Closes #17

See merge request riftenlabs/riftenlabs-indexer!50
2026-01-21 10:01:23 +00:00
Dagur Valberg Johannsson
6876dac6d2 Merge branch 'cache' into 'master'
Add Cache-Control headers to RPC endpoints for load balancer caching

See merge request riftenlabs/riftenlabs-indexer!49
2026-01-21 10:01:07 +00:00
Dagur Valberg Johannsson
e93d46ec69 Add Cache-Control headers to RPC endpoints for load balancer caching
Introduce CachedJson response wrapper with cache duration based on data mutability:
- CACHE_IMMUTABLE (1 day): historical data with explicit timestamps
- CACHE_BCMR (5 min): token metadata
- CACHE_AGGREGATE (60s): aggregate data that changes with blocks
- CACHE_NONE: real-time data (current price, active pools, latest txs)

Endpoints dynamically select cache duration based on whether time parameters
are explicitly provided (historical/immutable) or defaulted to now (live).
2026-01-21 10:37:55 +01:00
Dagur Valberg Johannsson
46fb62d29b Fix bcmr_failure unique constraint for multi-token transactions
Remove errant UNIQUE INDEX on (utxo, txid) that conflicted with the
PRIMARY KEY (token_id, utxo, txid). A single transaction can update
auth chains for multiple tokens, requiring the same (utxo, txid) pair
to exist with different token_ids. The unique index blocked this.

The index was also unnecessary - EXPLAIN QUERY PLAN shows the PRIMARY
KEY index is used for all bcmr_failure lookups.

Add test covering multi-token failure recording.
2026-01-21 10:17:49 +01:00
Dagur Valberg Johannsson
42aa74fc41 Merge branch '500-fixes' into 'master'
Fix incorrect 5XX responses for user input errors

See merge request riftenlabs/riftenlabs-indexer!48
2026-01-21 08:06:13 +00:00
Dagur Valberg Johannsson
2c76bf09c7 Fix incorrect 5XX responses for user input errors
Return proper 4XX status codes for client errors to prevent load balancers
from misinterpreting input validation failures as server errors. Add
centralized ApiResult type and ApiErrorCode enum for consistent handling.
2026-01-21 08:27:57 +01:00
Dagur Valberg Johannsson
b702abf8a8 Merge branch 'pool-id' into 'master'
Add RPC call to retrieve pool ID

See merge request riftenlabs/riftenlabs-indexer!47
2026-01-13 08:43:57 +00:00
Dagur Valberg Johannsson
50cd23dd34
Add RPC call to retrieve pool ID
Add a call that returns a pool ID given an utxo
2026-01-09 15:29:05 +01:00
Dagur Valberg Johannsson
46c3ff029a Merge branch 'chipnet' into 'master'
Add Chipnet support

See merge request riftenlabs/riftenlabs-indexer!46
2026-01-09 12:56:50 +00:00
Dagur Valberg Johannsson
a6c6159eba
Add Chipnet support 2026-01-09 13:46:58 +01:00
jakobsn
1b7801dff8 Merge branch 'manage-several-entries-one-txid' into 'master'
Manage several entries one txid

See merge request riftenlabs/riftenlabs-indexer!44
2025-11-17 09:21:51 +00:00
jakobsn
8fd14cc65b Manage several entries one txid 2025-11-17 09:21:51 +00:00
jakobsn
c90fef699b Merge branch '15-olando-auth-header-not-tracked' into 'master'
Resolve "Olando auth-header not tracked"

Closes #15

See merge request riftenlabs/riftenlabs-indexer!43
2025-11-07 13:53:47 +00:00
jakobsn
e053d52a76 Resolve "Olando auth-header not tracked" 2025-11-07 13:53:47 +00:00
Dagur Valberg Johannsson
9b624ece42 Merge branch 'olando-test' into 'master'
Add test for OLANDO authchain updates

See merge request riftenlabs/riftenlabs-indexer!42
2025-10-14 07:44:29 +00:00
Dagur Valberg Johannsson
20f17a220a
Add test for OLANDO authchain updates 2025-10-14 09:36:03 +02:00
Dagur Valberg Johannsson
861b9d16aa Merge branch 'volume-index' into 'master'
Add a volume index

See merge request riftenlabs/riftenlabs-indexer!41
2025-10-13 06:25:02 +00:00
Dagur Valberg Johannsson
6cf8749f34 Merge branch 'bcmr-index' into 'master'
Add index to BCMR lookup

See merge request riftenlabs/riftenlabs-indexer!39
2025-10-13 06:23:26 +00:00
Dagur Valberg Johannsson
ff3438ca9f
Add index to BCMR lookup 2025-10-08 14:03:20 +02:00
Dagur Valberg Johannsson
8be4cf894e
Add a volume index
Significantly improves cpu load of volume queries
2025-10-08 13:56:36 +02:00
jakobsn
e999c2e32d Merge branch '14-panic-occurred-attempt-to-multiply-with-overflow' into 'master'
Resolve "Panic occurred: attempt to multiply with overflow"

Closes #14

See merge request riftenlabs/riftenlabs-indexer!40
2025-10-03 13:32:37 +00:00
jakobsn
885dde9534 Resolve "Panic occurred: attempt to multiply with overflow" 2025-10-03 13:32:37 +00:00
jakobsn
36ec60e049 Merge branch '13-returnoldestpoolcreationtime' into 'master'
Expose first pool created timestamp

Closes #13

See merge request riftenlabs/riftenlabs-indexer!38
2025-09-17 10:11:32 +00:00
Jakob Notland
3b70e3e932 Format 2025-09-17 12:08:03 +02:00
Jakob Notland
af97a75540 Consider blockheight before timestamp 2025-09-17 12:05:24 +02:00
Jakob Notland
46462284e8 Clean 2025-09-17 11:52:22 +02:00
jakobsn
f702a454a4 Merge branch '12-incorrectvolumeforcandles' into 'master'
Resolve "incorrectVolumeForCandles"

Closes #12

See merge request riftenlabs/riftenlabs-indexer!37
2025-09-17 09:50:39 +00:00
jakobsn
93de5e04eb Resolve "incorrectVolumeForCandles" 2025-09-17 09:50:39 +00:00
Jakob Notland
4d2336d9d7 clean 2025-09-17 11:27:05 +02:00
Jakob Notland
7e7f5b9bc7 Expose first pool created timestamp 2025-09-17 11:11:21 +02:00
jakobsn
90b17a87a4 Merge branch '11-remove-zero-liq-tokens-from-cached-list' into 'master'
Delete zero-tvl tokens from cached list. Allow zero-tvl search on exact tokenId

Closes #11

See merge request riftenlabs/riftenlabs-indexer!36
2025-09-16 09:10:55 +00:00
jakobsn
6f25872ef7 Delete zero-tvl tokens from cached list. Allow zero-tvl search on exact tokenId 2025-09-16 09:10:54 +00:00
jakobsn
817b94efda Merge branch 'handleYoungTokenPriceDifferences' into 'master'
Handleyoungtokenpricedifferences

See merge request riftenlabs/riftenlabs-indexer!35
2025-09-11 07:36:06 +00:00
jakobsn
debe1630f4 Handleyoungtokenpricedifferences 2025-09-11 07:36:06 +00:00
jakobsn
4c207d312e
Merge branch 'goodSearchAndSort' into 'master'
Goodsearchandsort

See merge request riftenlabs/riftenlabs-indexer!33
2025-09-05 13:53:10 +00:00
jakobsn
f83f472656
Goodsearchandsort 2025-09-05 13:53:10 +00:00
Dagur Valberg Johannsson
821583b6e2 Merge branch 'bug-volume' into 'master'
bug: Fix volume for periods with no trades

See merge request riftenlabs/riftenlabs-indexer!32
2025-08-19 10:07:55 +00:00
Dagur Valberg Johannsson
8dc824860c
bug: Fix volume for periods with no trades
Return 0 in volume rather than query error.
2025-08-19 11:45:12 +02:00
Dagur Valberg Johannsson
304713d6e4 Merge branch 'improve-price' into 'master'
Improve pool visitor queries; make price a visitor

See merge request riftenlabs/riftenlabs-indexer!31
2025-08-19 09:39:34 +00:00
Dagur Valberg Johannsson
ec49bf765b
Improve pool visitor queries; make price a visitor
This adds a big performance boost to pool visitor queries, also moving
token price queries to use the visitor model.
2025-08-19 02:37:28 +02:00