celestia-node
celestia-node copied to clipboard
Reconsider behaviour for `GetRangeByHeight`
Current behaviour:
GetRangeByHeight
goes from to-1
-> from
, meaning for a request of [200:300] where the node only has [200:299], no headers would be returned an an err code ErrNotFound
is returned.
Desired behaviour:
GetRangeByHeight
should go from from
-> to-1
as far as it can (contiguously) and return partial headers as well as ErrNotFound
if only a partial range is returned.
from https://github.com/celestiaorg/celestia-node/pull/1135
Should we actually return an ErrNotFound
in situation where partial data is returned? I think it might lead to confusion with situation when there is no data at all. Also usually in api design if error is return, response data is not considered, but only error is handled. Maybe add another statusCodePartial to keep status explicit in situations when partial data is returned?
I agree with returning ErrNotFound instead of partial data, for the reason of partial data response being a very rare case that will complicate the implementation for very minimal gain. Currently, all peers have all the headers, in future with pruning, peers will have either peers with all headers or peers with headers for unboding window(3 weeks since head). If this changes it some point, we can reconsider making partial responses.