HomePhabricator

[Chronik] Add reverse lookup index, allow hashes in `/block/:hash_or_height`

Description

[Chronik] Add reverse lookup index, allow hashes in /block/:hash_or_height

Summary:
Currently, we can only query blocks by height, because we only index by height. To query by hash, we need an index from hash -> height. However, since we already store the hash in the blk column family, this would be redundant. While this seems trivial for blocks, this would incur not an insignificant redundant space for the equivalent index for txs, or other future reverse indices.

We therefore add the ReverseLookup struct, which (instead of storing a hash -> height) stores a cheaphash(hash) -> [height] column family, which stores a list of heights for each entry to allow for collisions. See details in reverse_lookup.rs.

Test Plan: ninja check-crates && ninja && ./test/functional/test_runner.py chronik_block

Reviewers: Fabien, #bitcoin_abc

Reviewed By: Fabien, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D13422

Details

Provenance
tobias_ruckAuthored on Mar 23 2023, 10:49
tobias_ruckPushed on Mar 23 2023, 17:44
Reviewer
Restricted Project
Differential Revision
D13422: [Chronik] Add reverse lookup index, allow hashes in `/block/:hash_or_height`
Parents
rABCea2829d5e969: Factorize the tx use count checks in blockencodings_tests
Branches
Unknown
Tags
Unknown