Skip to content

Commit

Permalink
Merge branch 'main' into exchange/head-single-flight
Browse files Browse the repository at this point in the history
  • Loading branch information
IliaBulavintsev authored Nov 6, 2024
2 parents 024407b + a15424a commit cb51900
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 2 additions & 4 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,8 @@ func (s *Store[H]) GetRange(ctx context.Context, from, to uint64) ([]H, error) {
}

func (s *Store[H]) getRangeByHeight(ctx context.Context, from, to uint64) ([]H, error) {
// as the requested range is non-inclusive in the end[from;to), we need to compare
// `from` with `to-1`
if from > to-1 {
return nil, fmt.Errorf("header/store: invalid range(%d,%d)", from, to-1)
if from >= to {
return nil, fmt.Errorf("header/store: invalid range(%d,%d)", from, to)
}
h, err := s.GetByHeight(ctx, to-1)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ func TestStore(t *testing.T) {
out, err = store.getRangeByHeight(ctx, 1, 13)
require.NoError(t, err)
assert.Len(t, out, 12)

out, err = store.getRangeByHeight(ctx, 10, 11)
require.NoError(t, err)
assert.Len(t, out, 1)
}

// TestStore_GetRangeByHeight_ExpectedRange
Expand Down

0 comments on commit cb51900

Please sign in to comment.