remove filter from doCopy; it's not used
it was there to support a potential CopyTo interface; but we'll cross that bridge when we get there.
This commit is contained in:
parent
649fc62863
commit
0baeec0686
@ -309,7 +309,7 @@ func (b *Blockstore) movingGC() error {
|
|||||||
b.unlockMove(moveStateMoving)
|
b.unlockMove(moveStateMoving)
|
||||||
|
|
||||||
log.Info("copying blockstore")
|
log.Info("copying blockstore")
|
||||||
err = b.doCopy(b.db, b.db2, nil)
|
err = b.doCopy(b.db, b.db2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error moving badger blockstore to %s: %w", path, err)
|
return fmt.Errorf("error moving badger blockstore to %s: %w", path, err)
|
||||||
}
|
}
|
||||||
@ -349,7 +349,7 @@ func (b *Blockstore) movingGC() error {
|
|||||||
|
|
||||||
// doCopy copies a badger blockstore to another, with an optional filter; if the filter
|
// doCopy copies a badger blockstore to another, with an optional filter; if the filter
|
||||||
// is not nil, then only cids that satisfy the filter will be copied.
|
// is not nil, then only cids that satisfy the filter will be copied.
|
||||||
func (b *Blockstore) doCopy(from, to *badger.DB, filter func(cid.Cid) bool) error {
|
func (b *Blockstore) doCopy(from, to *badger.DB) error {
|
||||||
count := 0
|
count := 0
|
||||||
batch := to.NewWriteBatch()
|
batch := to.NewWriteBatch()
|
||||||
defer batch.Cancel()
|
defer batch.Cancel()
|
||||||
@ -375,7 +375,6 @@ func (b *Blockstore) doCopy(from, to *badger.DB, filter func(cid.Cid) bool) erro
|
|||||||
}
|
}
|
||||||
defer putPooled()
|
defer putPooled()
|
||||||
|
|
||||||
var buf []byte
|
|
||||||
for iter.Rewind(); iter.Valid(); iter.Next() {
|
for iter.Rewind(); iter.Valid(); iter.Next() {
|
||||||
if !b.isOpen() {
|
if !b.isOpen() {
|
||||||
return ErrBlockstoreClosed
|
return ErrBlockstoreClosed
|
||||||
@ -384,28 +383,6 @@ func (b *Blockstore) doCopy(from, to *badger.DB, filter func(cid.Cid) bool) erro
|
|||||||
item := iter.Item()
|
item := iter.Item()
|
||||||
|
|
||||||
kk := item.Key()
|
kk := item.Key()
|
||||||
if filter != nil {
|
|
||||||
k := kk
|
|
||||||
if b.prefixing {
|
|
||||||
k = k[b.prefixLen:]
|
|
||||||
}
|
|
||||||
|
|
||||||
klen := base32.RawStdEncoding.DecodedLen(len(k))
|
|
||||||
if klen > len(buf) {
|
|
||||||
buf = make([]byte, klen)
|
|
||||||
}
|
|
||||||
|
|
||||||
n, err := base32.RawStdEncoding.Decode(buf, k)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
c := cid.NewCidV1(cid.Raw, buf[:n])
|
|
||||||
if !filter(c) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
k := getPooled(len(kk))
|
k := getPooled(len(kk))
|
||||||
copy(k, kk)
|
copy(k, kk)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user