Skip to content

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 9bf7907.Fix bug introduced in 9bf7907.


This commit was moved from ipfs/go-ipfs-provider@ef94782
  • Loading branch information
Jorropo committed Dec 9, 2022
1 parent 5341e61 commit 7f24945
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions provider/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 7f24945

Please sign in to comment.