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

feat: introduce new type of error #157

Open vgonkivs opened 4 months ago

vgonkivs commented 4 months ago

After pruning is finished + backward sync is introduced, our ErrNoFound will have 2 meanings: 1) The Node is still syncing and hasn't synced to the requested height yet; 2) The node does not have this height and will not sync on it in the future;

As it will confuse us and users, we should agree and differentiate these two cases by introducing one more error for the first case -> ErrNotSynced.

cc @renaynay

renaynay commented 4 months ago

Need to think about this more but sounds good from first thought.

Wondertan commented 4 months ago

This will also need a new error type on the protocol that peers can lie about. One can always say ErrNotSynced to make other peers always retry it, even when it won't have it.

If we keep retrying other peers and backoff everyone independently of ErrNotSynced this problem disappears, but then the benefits of this separation disappear as well.