Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
fix: make queue 64bits on 32bits platforms too
Browse files Browse the repository at this point in the history
`int` is 32bits on 32bits platforms, it is realistical that you would overflow it (afaik by having more than 2b blocks in one datastore)
Also we don't need 63 leading digits, a uint64 can always be represented in 20 base 10 digits.

Fix bug introduced in 53fe9d8.Fix bug introduced in 53fe9d8.
  • Loading branch information
Jorropo committed Dec 9, 2022
1 parent 7a606d0 commit ef94782
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions queue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type Queue struct {
close context.CancelFunc
closed chan struct{}

counter int
counter uint64
}

// NewQueue creates a queue for cids
Expand Down Expand Up @@ -117,7 +117,7 @@ func (q *Queue) work() {

select {
case toQueue := <-q.enqueue:
keyPath := fmt.Sprintf("%063d/%s", q.counter, c.String())
keyPath := fmt.Sprintf("%020d/%s", q.counter, c.String())
q.counter++
nextKey := datastore.NewKey(keyPath)

Expand Down

0 comments on commit ef94782

Please sign in to comment.