celestiaorg / go-header

Go library with all the services needed to request, sync and store blockchain headers.
Apache License 2.0
17 stars 16 forks source link

store: Implement `Tail` method on Store interface #203

Open renaynay opened 4 days ago

renaynay commented 4 days ago

Tail should track the "lowest" header height written to the Store that is contiguous to the head of the store.

This means everything between store.Head and store.Tail should be adjacent and written to the store.

Screenshot 2024-06-24 at 16 58 37

For now, since syncer is still forward-syncing and the genesis header is requested first, Tail should always be == genesis (height 1).

Once backwards sync is implemented inside the syncer, Tail will actually need to track store writes to ensure that it is the lowest (oldest) contiguous header written to the disk.

Implementation detail (potentially to be discussed if needed): Nothing should be written to the store that is below the Tail().Height(), so store should short-circuit if there is an Append that is attempted for a height that is less than Tail().Height()-1.