Converts the materialized-path aggregation from pure SQL (pure-net-ratio formula) to Rust streaming with the per-leg policy core, ensuring raw and materialized paths use identical logic and reject identical legs. Changes: - rebuild_range: three-phase approach: 1. Fetch per-leg data for confirmed txs (WHERE blockhash IS NOT NULL) 2. Fold through each token's legs using Policy to compute hour buckets 3. Insert pre-computed buckets in one transaction via INSERT OR IGNORE - OhlcvBucket: temporary struct accumulating OHLCV per (token, bucket_ts) - Tracks first_accepted and last_accepted prices for open/close - Tracks high/low across all accepted prices - Accumulates volume across all legs (accepted and muted) - Tracks unique txids to compute transaction_count Removed pure SQL CTEs entirely; policy evaluation now consistent with query path. Tests: 222 passing (fixed test expectation for per-leg prices) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| .vscode | ||
| contrib | ||
| internal | ||
| linters | ||
| src | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| build.rs | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
Riftenlabs Indexer
RiftenLabs indexer is for indexing DeFi contracts by Riften Labs. It allows for querying historical on-chain data on Bitcoin Cash.
Contributing
All contributors are required to sign a Contributor License Agreement (CLA) before their contributions can be merged into the project.
Contributions are generally welcome. If you intend to make larger changes please discuss them in an issue before MRing them to avoid duplicate work and architectural mismatches.
Installing Rust
Rust can be installed using your package manager of choice or rustup.rs. The former way is considered more secure since it typically doesn't involve trust in the CA system. But you should be aware that the version of Rust shipped by your distribution might be out of date.
Building
The library can be built and tested using cargo:
git clone https://gitlab.com/riftenlabs/riftenlabs-indexer.git
cd riftenlabs-indexer
cargo build
You can run tests with:
cargo test