txpipe / pallas

Rust-native building blocks for the Cardano blockchain ecosystem
Apache License 2.0
140 stars 58 forks source link

Fuzzy search for block in Immutable data by point only. #484

Closed stevenj closed 2 months ago

stevenj commented 2 months ago

This adds a feature where if the Point used in read_blocks_from_point() does not have a hash (zero length) then the search will look for the first block that equals or exceeds the given slot#, and the hash is ignored.

It is fully backwards compatible with the existing behavior and just allows the immutable data to be probed. That is, if a point/hash is given, the search is strict and both must match.

One potential use cases include extracting a section of the immutable data bounded by time, as slot# can be converted too and from a time for any particular blockchain.

Another is doing relative searches, such as returning the blocks up to n slots before a known slot#/hash.

We use both of these features in the cardano-chain-follower crate being developed here: https://github.com/input-output-hk/hermes/pull/266