[#791] blobovnicza: Don't iterate over range buckets in Iterate

`Blobovnicza` can be initialized with any number of range buckets, and
reconstructed with different size limit. In previous implementation
`Iterate` could miss some stored objects if we construct `Blobovnicza` with
smaller number of ranges.

Make `Iterate` to traverse all buckets regardless of current instance
bounds.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-09-14 17:32:05 +03:00 committed by Leonard Lyubich
parent 5e2ca0d04b
commit cc5d3288a1

View file

@ -116,8 +116,8 @@ func (b *Blobovnicza) Iterate(prm IteratePrm) (*IterateRes, error) {
var elem IterationElement
if err := b.boltDB.View(func(tx *bbolt.Tx) error {
return b.iterateBuckets(tx, func(lower, upper uint64, buck *bbolt.Bucket) (bool, error) {
err := buck.ForEach(func(k, v []byte) error {
return tx.ForEach(func(name []byte, buck *bbolt.Bucket) error {
return buck.ForEach(func(k, v []byte) error {
if prm.decodeAddresses {
if elem.addr == nil {
elem.addr = object.NewAddress()
@ -134,8 +134,6 @@ func (b *Blobovnicza) Iterate(prm IteratePrm) (*IterateRes, error) {
return prm.handler(elem)
})
return err != nil, err
})
}); err != nil {
return nil, err