Skip to content

Commit

Permalink
return v1 and v0 cids in AllKeysChan
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Mar 9, 2024
1 parent 7a0f68b commit 232592f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion renterd/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
format "github.com/ipfs/go-ipld-format"
"github.com/multiformats/go-multicodec"
"github.com/multiformats/go-multihash"
"go.sia.tech/renterd/api"
"go.sia.tech/renterd/bus"
"go.sia.tech/renterd/worker"
Expand Down Expand Up @@ -190,14 +192,25 @@ func (bs *BlockStore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) {
return
}

log.Debug("got root CIDs", zap.Int("count", len(cids)))
log.Debug("got pinned CIDs", zap.Int("count", len(cids)))
for _, c := range cids {
select {
case ch <- c:
case <-ctx.Done():
close(ch)
return
}

// since only the v1 CID is stored, try to convert it to v0
if c.Type() == uint64(multicodec.DagPb) && c.Prefix().MhType == multihash.SHA2_256 {
cv0 := cid.NewCidV0(c.Hash())
select {
case ch <- cv0:
case <-ctx.Done():
close(ch)
return
}
}
}
}
}()
Expand Down

0 comments on commit 232592f

Please sign in to comment.