from: BlockId
and to: Option<BlockId>
.What we want is an API to fetch blocks from the storage layer (assume that the tip is from carnot/info
api).
We have:
sled
is an ordered storage by key, but our block hash does not have a valid Ord implementation, so the order in db cannot reflect the order we store those blocks)We face:
get(id: BlockId)
on sled
N times, N is the gap between from
and to
. This leads to bad performance and expensive overhead, because the actual IO operations are M x N times, where M < N.We can improve:
from: BlockNumber
, to: Option<BlockNumber>
. In storage side, we can directly fetch all of N blocks by list(range: Range<BlockNumber>)
. In this way, we need M IO operations.A while loop, we find from
first, and call parent to get the parent block, and continue until we reach to
.
Add index information like BlockNumber
, so that we can improve the query performance signaficantly.