From 7f249456102362475b5ca6b9f8f602e9c95813bb Mon Sep 17 00:00:00 2001 From: Jorropo Date: Fri, 9 Dec 2022 13:31:02 +0100 Subject: [PATCH] fix: make queue 64bits on 32bits platforms too `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 9bf7907fe1cf811df1328255c953028569c00087.Fix bug introduced in 9bf7907fe1cf811df1328255c953028569c00087. This commit was moved from ipfs/go-ipfs-provider@ef94782b5be979858fa8e4c57c68308dab035d7e --- provider/queue/queue.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/provider/queue/queue.go b/provider/queue/queue.go index d2ba30a79..618256bbe 100644 --- a/provider/queue/queue.go +++ b/provider/queue/queue.go @@ -28,7 +28,7 @@ type Queue struct { close context.CancelFunc closed chan struct{} - counter int + counter uint64 } // NewQueue creates a queue for cids @@ -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)